React Functional component: calling as function vs. as component

If you call functional component directly, you are calling a custom hook actually.


function A() {
  const [state] = useState([])
  return (

<A />

If you call A(), the state mounts in parent fiber, but if you use <A />, React will call createElement to create a new fiber on which to mount state.

Leave a Comment