Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

159
Visualizações
Should I set initial state in the reducer default arguments or in the default store?

I am using redux, and need default values for my app state. For example the default User is false as by default nobody is signed in.

Should I set this in the reducer itself as follows:

const User = (state = {current: false}, action) => {

Or should I set them in the default store as follows:

import defaultstore from './defaultstore';

const store = createStore(reducers, defaultstore, middleware);

Which is preferred? What are the pros and cons?

I find Redux documentation confusing as they use default values directly in the reducer here, but at the same time they pass them in as the second argument in createStore.

How do I know which is best, i.e. requires less maintenance ( less refactoring, easy troubleshooting ), works efficiently ( Big O ).

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda