Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

115
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!