complete-intro-to-react-v8 icon indicating copy to clipboard operation
complete-intro-to-react-v8 copied to clipboard

Probably incorrect/misleading paragraph in B-Hooks.md

Open aleksanderantropov opened this issue 2 years ago • 0 comments

In B-Hooks.md there is a paragraph:

Now navigate to [http://localhost:5173/](https://react-v8.holt.courses/lessons/core-react-concepts/hooks) and see that your have one input box that says "Seattle, WA". Try and type in it. You'll see that you can't modify it. Why? Let's think about how React works: when you type in the input, React detects that a DOM event happens. When that happens, React thinks something may have changed so it runs a re-render. Providing your render functions are fast, this is a very quick operation. It then diffs what's currently there and what its render pass came up with. It then updates the minimum amount of DOM necessary.

and

So if we type in our input and it re-renders, what gets out in the input tag? Well, its value is tied to location and nothing changed that, so it remains the same. In other words, two way data binding is not free in React. I say this is a feature because it makes you explicit on how you handle your data. Let's go make it work.

But React doesn't run a rerender when state doesn't change. In this example it simply doesn't rerender.

aleksanderantropov avatar Nov 22 '22 18:11 aleksanderantropov