4 ms·
What do you think you're doing when you call render(<App />,...)?
by throwAGIway 2y ago
What do you think you're doing when you call render(<App />,...)?
- recursive 2y agoNot 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.
- throwAGIway 2y agoThe 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.
- recursive 2y agocreateElement is immediate. The component function call is not. It may never be called. Try const a = <App />; App() will never be called.
- throwAGIway 2y agoYeah, 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.
- recursive 2y agoWhen 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.