React ref Callback Use-Cases
ref callbacks are a little known feature in React, they’re used to perform an action when React attaches or detaches a ref to a DOM element. ref callbacks have a few use-cases, let’s look at some.
Hello I’m Jules. I studied Applied Geosciences but now I’m a Software Developer. I’m most experienced with web frontend, specifically React & D3. I’m passionate about building tools on the web and data visualization.
You can find me on the web on Twitter, GitHub, or Observable.
ref callbacks are a little known feature in React, they’re used to perform an action when React attaches or detaches a ref to a DOM element. ref callbacks have a few use-cases, let’s look at some.
An explorable visualization of the modern HTML elements.
An interactive timeline showing how a React component with hooks runs including a quiz of React Riddles to test your knowledge.
Cleaner conditional rendering in React by matching values using component maps, optionally, lazy-load components to make a “lazy component map”
useReducer is not just for complex state-updating logic, it can be used for commonplace state updates; state updates that are not not complex, and not super simple either; medium reducers for mundane state updating logic.