Redux Toolkit Notes
Redux Toolkit Notes
SLice:
We can organise our store data in small pieces.
It automatically generates action creators and action types based on the reducers
you define.
With Redux Toolkit's createSlice, you can define reducers directly inside the
slice, making it more concise and readable.
Reducers:
Reducers are functions that specify how the application's state changes in response
to actions sent to the Redux store.
Reducers are pure functions which are used to change the state.
store.
useDispatch:
useReducer is used to manage the local component state
useSelector:
useSelector is a React Redux hook that allows you to extract data from the Redux
store state.
Redux-Thunk:
Thunk is a middleware in redux. It is inbuilt in rtk.
Think is a normal function. And it returns a new function that is async.
We can use thunk by 2 methods. one is old redux method. one is used in redux
toolkit. so in redux toolkit we have to use createASYNCThunk function and also we
have to create cases first for our actions.
Note: We have to use redux when our data is being used in multiple components.