Redux-toolkit helps us to significantly reduce boilerplate in the redux layer of our applications. If you’re not familiar with redux-toolkit you can reference  official documentation .

One downside of this code, is that it’s not possible to reuse types of actions and action payloads setTodoStatus and removeTodo. For example if you need to reuse action type in a middleware handler (e.g. redux-saga). One simple solution would be to extract those as separate types:

type SetTodoPayload = { id: string; done: boolean; };
type RemoveTodoPayload = { id: string };

#redux #typescript #redux-toolkit

Typing Actions and Action Payloads for Redux-toolkit
1.65 GEEK