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

122
Visualizações
How to set preloadedState in redux store with only one pice of state in typescript?
export const rootReducer = combineReducers({
      landingInfo: landingReducer,
      features: featuresReducer,
      reviews: reviewsReducer,
      promotions: promotionsReducer,
      rewards: rewardsReducer,
      appointments: appointmentsReducer,
      userView: userViewReducer,
      isMenuOpen: toggleMenuReducer,
      isUserAuthenticated: authenticationReducer
    })
    
    export type RootState = ReturnType<typeof rootReducer>

This is my reducers/index.ts ^^^

const preloadedState = {isUserAuthenticated: { ...defaultValues.USER, token: secureToken }}
const store = createStore(rootReducer, preloadedState, composeWithDevTools(applyMiddleware(thunk)))

render(
   <Provider store={store}>
      <App/>
   </Provider>,
   document.getElementById('root'))

There at line 2 I got this error

TS2345: Argument of type '{ isUserAuthenticated: { token: string; name: string; userId: string; }; }' is not assignable to parameter of type '{ landingInfo?: undefined; features?: undefined; reviews?: undefined; promotions?: undefined; rewards?: undefined; appointments?: undefined; userView?: undefined; isMenuOpen?: undefined; isUserAuthenticated?: undefined; }'.   Types of property 'isUserAuthenticated' are incompatible.     Type '{ token: string; name: string; userId: string; }' is not assignable to type 'undefined'.

Ok... I understood that I need to put in preloadedState initial state all of my redux state. Is there a way through I can put only a pice of state?

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