DEV Community

Discussion on: Redux Toolkit and Typescript (the best way to manage application state)

Collapse
 
jivkojelev91 profile image
JivkoJelev91

There is no need to type the store in every component. You can skip it like that:

export type RootState = ReturnType<typeof rootReducer>;
export type AppDispatch = typeof store.dispatch;
export const useAppDispatch = (): AppDispatch => useDispatch<AppDispatch>();
export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector;
Enter fullscreen mode Exit fullscreen mode