|
|
|
|
|
by qudat
566 days ago
|
|
> It seems you only want to call MVC frameworks frameworks? No, I'm illustrating the limited scope of React. I wouldn't call a chunk of code that handles the V in MVC a framework. > for which the definition is usually the calls into you/you call into it thing Again there's nuance here: import { useEffect, useState } from "react";
import { createRoot } from 'react-dom/client';
document.body.innerHTML = '<div id="app"></div>';
const root = createRoot(document.getElementById('app'));
root.render(<App />);
function App() {
const counter = useState(0);
useEffect(() => { console.log('effect') }, []);
return <h1>hello world: {counter}</h1>
}
I'm "calling into" react (3) times here, while react is calling "into me" (1) time. Are we saying any external source code that accepts a function as a parameter is considered a framework?All react does is render/diff/patch your dom, everything else is up to the end-developer. Would you call `express` a framework? Again this is semantics but look at all the react frameworks that exist on top of react, why do those exist? |
|
It's calling into you three or more times, invisibly, if I remember the details of what useEffect and useState actually do at runtime correctly. Which rather illustrates the point.
> Are we saying any external source code that accepts a function as a parameter is considered a framework?
Code that accepts a function for narrowly scoped use where the control flow is still under your control (e.g. map/reduce/filter libraries) is probably not a framework. But external code where you register a callback that gets called some time later, not under your control, is pretty much the definition of a framework.