Affected files: .obsidian/workspace.json 2 Personal/1 Skills/IT/React Learnings.md
20 lines
1.0 KiB
Markdown
20 lines
1.0 KiB
Markdown
---
|
||
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).
|
||
|
||
## Cool Projects
|
||
- [GitHub - glowbuzzer/gbt: Glowbuzzer tools](https://github.com/glowbuzzer/gbt)
|
||
- |