Fantastic closures and how to find them in React

Developer Way
Developer Way
9.1 هزار بار بازدید - 11 ماه پیش - 👉 Advanced React Book:
👉 Advanced React Book: https://www.advanced-react.com
👉 Fantastic closures and how to find them in React: https://www.developerway.com/posts/fa...

💬 Twitter: Twitter: adevnadia
💬 Linkedin: LinkedIn: adevnadia

👩🏼‍💻 Initial "mystery" code example: https://codesandbox.io/s/example1-925...
👩🏼‍💻 Cached closure without React code example: https://codesandbox.io/s/example2-xx4xq3
👩🏼‍💻 "Mystery" app fixed with the solution code example: https://codesandbox.io/s/example5-h3j...

Closures in JavaScript must be one of the most terrifying features of the language. Even the omniscient ChatGPT will tell you that. It’s also probably one of the most hidden language concepts. We use it every time we write any React code, most of the time without even realizing it. But there is no getting away from them in the end: if we want to write complex and performant React apps, we have to know closures.

So let’s dive into yet another code mystery, and in the process learn:

* What closures are, how they appear, and why we need them.
* What a stale closure is, and why they occur.
* What the common scenarios in React are that cause stale closures, and how to fight them.

#react #reactjs #webdevelopment #programming #frontend #frontenddeveloper #js #javascript
11 ماه پیش در تاریخ 1402/05/23 منتشر شده است.
9,153 بـار بازدید شده
... بیشتر