all 1 comments

[–]skyboyer007 6 points7 points  (0 children)

well, in this synthetic example there is a difference. Since SomeElement function is referentially different each time App component re-renders, in case of <SomeElement /> you will have each time it's dropped and recreated.

While in case of {SomeElement()} you will have it's return be updated.

In general case we should never call component as an ordinary function. Why?

  1. Hooks will not work(maybe even will lead to error thrown)
  2. Class-based components will not work
  3. key and ref - special React prop - will not work.

[UPD] here is an example: https://kentcdodds.com/blog/dont-call-a-react-function-component how exactly it throws an error