3 ms·
It's a leaky abstraction at best. Obviously leaving out the ones that are literally written to the DOM, can you give some more examples of React props (like 'c
by hashkb 6y ago
It's a leaky abstraction at best. Obviously leaving out the ones that are literally written to the DOM, can you give some more examples of React props (like 'children') that are helpful to think about in this way?
I wrote vanilla JS for years, then Backbone, then Angular, and now React. I am the counterexample to your second sentence. My "intuitive understanding" is that props are actually keys in a plain-ol' JS function argument, and I'm sure that you're handicapping yourself if you're going out of your way to map React concepts to DOM concepts. This is why people find hooks so confusing and weird, because they're trying so hard to map it to some other concept. See the many comments about JSX in this thread - the more you try force React ideas into your preconceptions about web dev, the worse time you'll have.
- sfvisser 6y agoI’m sorry if there was a misunderstanding, but I was talking about the children prop specifically, not props in general. That would be different story.
- kosievdmerwe 6y agoYeah hooks are much easier if you just accept them as a new "language feature" that magically works. Still have no real idea how it's implemented, but it's pretty simple once you stop trying to overanalyze it.
- acemarke 6y agoShort version: React already knows what component instance it's rendering. Whenever a hook is called, React looks up the right data from a linked list stored in the internal component metadata objects. For more details, see: - Shawn Wang's talk "Getting Closure on Hooks": https://www.swyx.io/getting-closure-on-hooks/ https://www.swyx.io/getting-closure-on-hooks/ - React Hooks Demystified: https://dev.to/kayis/react-hooks-demystified-2af6 https://dev.to/kayis/react-hooks-demystified-2af6 - React Hooks - Not Magic, Just Arrays: https://medium.com/@ryardley/react-hooks-not-magic-just-arrays-cd4f1857236e https://medium.com/@ryardley/react-hooks-not-magic-just-arra... - additional articles: https://github.com/markerikson/react-redux-links/blob/master/react-hooks.md#understanding-hooks-concepts https://github.com/markerikson/react-redux-links/blob/master...