Build Social Media Feed App with Redux & Tailwind CSS in React: PART 2

preview_player
Показать описание
Redux state is updated by "reducer functions":

✂️ Reducers always calculate a new state immutably by copying existing state values and modifying the copies with the new data.
🧩 The Redux Toolkit createSlice function generates "slice reducer" functions for you, allowing you to write "mutating" code that is safely converted into immutable updates.
🏗️ These slice reducer functions are added to the reducer field in configureStore, defining the data and state field names within the Redux store.
🖥️ React components read data from the store using the useSelector hook:
🧐 Selector functions receive the entire state object and should return a specific value.
🔄 Selectors will re-run whenever the Redux store is updated, and if the data they return has changed, the component will re-render.
📤 React components dispatch actions to update the store using the useDispatch hook:
🚀 createSlice will generate action creator functions for each reducer added to a slice.
🔄 Call dispatch(someActionCreator()) in a component to dispatch an action.
⚙️ Reducers will run, check if the action is relevant, and return new state if appropriate.
📝 Temporary data like form input values should be kept as React component state. When the user completes the form, dispatch a Redux action to update the store.

Рекомендации по теме
Комментарии
Автор

Thank you for watching. Please like, share, and subscribe to my channel to support me.

codecraft