3 ms·
> Other way around, actually: "functional" components end up represented by an object. No, they're functions.
by robertoandred 4y ago
> Other way around, actually: "functional" components end up represented by an object.
No, they're functions.
- yamtaddle 4y agoWeren't as of a couple years ago—they're represented by an object in the React code. Not the case anymore? I'd be surprised if they'd messed with that, it seemed pretty fundamental to how it operated—hooks were implemented on top of that, for one thing.
- robertoandred 4y agoNope, just functions. Hooks are also just functions; their "magic" comes from them being called in the same order in a component.
- yamtaddle 4y agoOK, so the core of React changed and they no longer use a "functional" component to build a component object, which used the be the primary data structure in the state-machine-like engine at the heart of react, and to which they used to attach the lists that contain a component's hooks? That's all changed?
- acemarke 4y agoThe two of you are talking past each other :) Component _types_ are defined as either classes (`class MyComponent extends React.Component`), or functions (`function MyComponent(props) {}`). Internally, React has a "Fiber" data structure that stores references to that component type for each component instance, as well as a lot of other metadata. That's the _real_ "component tree": - https://blog.isquaredsoftware.com/2020/05/blogged-answers-a-mostly-complete-guide-to-react-rendering-behavior/#component-metadata-and-fibers https://blog.isquaredsoftware.com/2020/05/blogged-answers-a-...