I’m having to do frontend dev for the first time in nearly ten years. We’re using react and a lot has changed. Does anyone have a good explanation of how to think about react hooks? The react docs are handwavy.

#react #javascript #webdev #frontend

@jnkrtech if you have any familiarity with how react worked before hooks (class components with separate constructor, shouldComponentUpdate, and render functions) then the original reactconf talk where hooks were introduced is pretty helpful in showing how one conceptual frame maps into the other
(https://youtube.com/watch?v=dpw9EHDh2bM, the example we're thinking of starts at about 20m)

the main goal of the change was to make it easier to group related state, side effects, update logic, etc together; particularly in ways that can be wrapped up into a single unit (a "custom hook") and easily consumed from several components

internally this works by counting the number of times hooks are called from a component (and in what order), and so that react can track which state value corresponds to which internal hook field and do things like retrieve the state, compare effect sentinels to the previous value, etc

to our knowledge none of it relies on exceptions (except for Suspence but that's its own deal)

React Today and Tomorrow and 90% Cleaner React With Hooks

YouTube
@tempest thank you! I’ll watch this too