Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

120
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda