3 ms·
React started with class components, because of state, I guess. Later they added function components because they are more concise and tell readers that this c
by k__ 8y ago
React started with class components, because of state, I guess.
Later they added function components because they are more concise and tell readers that this component is a simple mapping from props to virtual DOM elements.
With hooks, a recent addition to React, they seem to move away from class components. Hooks enable you to use state and do things when a component is mounted in the DOM or removed from it inside of function components.