Arrays, Events, and the Little Details That Make React Feel Real
Today felt like one of those sessions where you keep pulling a thread and more things keep unravelling. A mix of JavaScript utility tricks, how browser events actually work under the hood, and some...

Source: DEV Community
Today felt like one of those sessions where you keep pulling a thread and more things keep unravelling. A mix of JavaScript utility tricks, how browser events actually work under the hood, and some solid React form habits. Good day. Array.from — Creating Arrays Out of Thin Air Sometimes you don't have data to map over — you just need to generate a list of numbers. Array.from is perfect for this: Array.from({length: 10}, (_, i) => i + 1) This creates [1, 2, 3, ... 10] from nothing. The _ is just the value parameter we don't care about — i is the index, and we add 1 so it starts from 1 instead of 0. Clean and no loops needed. And since it returns a plain array, you can chain .map() right onto it: Array.from({length: 10}, (_, i) => i + 1).map((index) => <Component key={index} />) One line, generates your array and renders your components. Very satisfying once it clicks. WSL + Docker Desktop Issues — You're Not Alone If you've hit weird issues with WSL and Docker Desktop not