Re:Understanding React Compiler
by erik_seaberg on Friday June 28, 2024 @03:42PM
(#40824451)
You call a library as you see fit. A framework calls you.
Oh yeah. I guess that's why we always invoke function components directly. Because it's a library.
/s
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 />,...)?
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.
I always disliked the it’s a library not a framework debate. Isn’t any library a framework, technically?