vault backup: 2025-05-17 12:21:31
Affected files: .obsidian/workspace.json .obsidian_iphone/plugins/obsidian-spaced-repetition/data.json .obsidian_iphone/workspace-mobile.json 2 Personal/1 Skills/IT/React Learnings.md
This commit is contained in:
16
2 Personal/1 Skills/IT/React Learnings.md
Normal file
16
2 Personal/1 Skills/IT/React Learnings.md
Normal file
@@ -0,0 +1,16 @@
|
||||
---
|
||||
title: React Learnings
|
||||
created_date: 2025-05-17
|
||||
updated_date: 2025-05-17
|
||||
aliases:
|
||||
tags:
|
||||
---
|
||||
# React Learnings
|
||||
|
||||
## State Machine - Reducers
|
||||
Reducers are what they are named after: they reduce the current state variable and an action/event into a new state and therefore are perfect for handling state machines of complex components within a react app.
|
||||
The official documentation is really good: [useReducer – React](https://react.dev/reference/react/useReducer) and this blog article helped me as well: [Medium](https://medium.com/better-programming/simplify-your-react-components-state-with-a-state-machine-8e9c9a4ee1f6)
|
||||
|
||||
Reducers are pure, so within the reducer function you never do any API calls or anything that needs to do calculations.
|
||||
|
||||
If you need to do any API calls or heavy calculations they must be done outside of the reducer function as explained here: [Just a moment...](https://stackoverflow.com/questions/64419132/how-to-make-api-call-in-usereducer).
|
||||
Reference in New Issue
Block a user