Avoid this React State Mistake | React Previous State Explained

Опубликовано: 27 October 2024
на канале: Dave Gray
35,555
1.1k

Web Dev Roadmap for Beginners (Free!): https://bit.ly/DaveGrayWebDevRoadmap

In this tutorial, React Previous State is explained. I will also explain why using setState with count + 1 is NOT wrong... but updating previous state in React requires an understanding of how state and re-rendering work together.

🚩 Subscribe ➜ https://bit.ly/3nGHmNn

🚀 React JS for Beginners full course - 9 hours:    • React JS Full Course for Beginners | ...  

Avoid this React State Mistake | React Previous State Explained

(00:00) Intro
(00:05) count + 1 is NOT wrong
(01:12) Know when to use the right tool
(01:28) The Golden Rule
(02:09) Previous State function example
(03:05) Why prefer the prevState function
(07:28) Previous state with arrays
(10:03) Previous state with objects
(12:06) Summary

🔗 ES7 React JS Snippets Extension for VS Code:
https://marketplace.visualstudio.com/...

🔗 React Dev Tools Extension for Chrome:
https://chrome.google.com/webstore/de...

📚 References:
ReactJS Official site: https://reactjs.org/
React Wikipedia: https://en.wikipedia.org/wiki/React_(...)
React Jobs: https://www.ziprecruiter.com/candidat...

✅ Follow Me:
Twitter:   / yesdavidgray  
LinkedIn:   / davidagray  
Blog: https://yesdavidgray.com
Reddit:   / daveoneleven  

Was this tutorial about understanding Previous State in React helpful? If so, please share. Let me know your thoughts in the comments.

#react #previous #state