News for hackers. Stuff that matters.
Re:Understanding React Compiler by rafark on Friday June 28, 2024 @01:29PM (#40822861)
>For almost 10 years, the core react developers would repeat incessantly: React is a library, not a framework.

I always disliked the it’s a library not a framework debate. Isn’t any library a framework, technically?

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.
Re:Understanding React Compiler by recursive on Friday June 28, 2024 @05:46PM (#40825608)
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 />,...)?
Re:Understanding React Compiler by recursive on Saturday June 29, 2024 @11:08AM (#40831128)
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.
Re:Understanding React Compiler by recursive on Saturday June 29, 2024 @06:57PM (#40833856)
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.
Re:Understanding React Compiler by recursive on Sunday June 30, 2024 @11:31AM (#40837750)
When you combine that with the fact that you can't invoke the function directly, this seems like the textbook definition to me. Agree to disagree I guess.