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

242
Visualizações
Possible to add a reducer that can read from multiple state slices?

I am using createSlice to create slices of state. Let's call them sliceA and sliceB. Mostly these slices are decoupled from each other. However I would like to create one reducer in sliceA that has (read) access to both sliceA and sliceB. Is this possible?

I know I can use extraReducers to accept actions that were not defined in the slice. But I think I would still be limited (in these extra reducers) to read only sliceA, and not sliceB.

Any idea how I could create a reducer that can read from both slices?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

By default, you can't. Each slice reducer is a standalone encapsulated function that can only see its own state.

Per the Redux FAQ entry on "How can I share state across slices?", your main options are:

  • Reorganize the state tree so that all the needed state is in one place
  • Use an additional "top-level reducer" to run more logic
  • Put more of the relevant data into the action
about 4 years ago · Juan Pablo Isaza Relatório
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