Re:Understanding React Compiler
by throwAGIway on Saturday June 29, 2024 @09:39AM
(#40830424)
What do you think you're doing when you call render(<App />,...)?
[ Parent
| on HN ]
Not calling App. Creating a react element with a reference to the function. The reconciler will call it later, asynchronously. Put in some console logs and see the order of operations for yourself.
Also, try calling App and see what happens if it uses hooks.
Re:Understanding React Compiler
by throwAGIway on Saturday June 29, 2024 @04:58PM
(#40833313)
The createElement function is called immediately, and it immediately calls your component function. I don't think this is a significant difference. Many libraries accept a callback and I'm really not ready to call all that a framework just based on that.
createElement is immediate. The component function call is not. It may never be called. Try const a = <App />;
App() will never be called.
Re:Understanding React Compiler
by throwAGIway on Sunday June 30, 2024 @02:40AM
(#40835511)
Yeah, it will be called when you call render as in my original comment. Again, I don't think that passing a callback makes a framework.