3 ms·
I think this poster is missing the key insight that React components are indeed nothing more than functions. If anyone is reading this right now go console.log
by zarathustreal 5y ago
I think this poster is missing the key insight that React components are indeed nothing more than functions. If anyone is reading this right now go console.log the output of your component, it's an object that describes the DOM output. Logic should not live in components, React is a rendering library. Make use of higher-order functions. Make use of a proper state management solution. Don't over-use hooks. It's really that simple.
- eliseumds 5y agoThey're definitely more than simple functions if you look at it from the the entire application point-of-view. With components you have access to context and lifecycle. Doing: import someFunc from 'someFunc'; // ... return someFunc(); is not the same as: import SomeComponent from 'SomeComponent'; // ... return <SomeComponent />
- karottenreibe 5y agoIt all depends on how the component is written. And the function. The function could access global variables for example. The component could be pure and not use context. Neither of which you can tell just by looking at the import statement.