japgolly / scalajs-react

Facebook's React on Scala.JS
https://japgolly.github.io/scalajs-react/
Apache License 2.0
1.64k stars 231 forks source link

Reusability in functional components via React.memo instead of class component #1089

Closed rpiaggio closed 5 months ago

rpiaggio commented 5 months ago

shouldComponentUpdate hook and renderWithReuse use an embedded class component to achieve reusability.

This PR changes the approach to the recommended use of React.memo for this purpose. This avoids having to mix functional and class components.

Furthermore, I'm having trouble making class components work with React 18. This unlocks the use of React 18 for apps with purely functional components.

cquiroz commented 5 months ago

Would it make sense to make a partial release for React 18 with only functional components support?

rpiaggio commented 5 months ago

Would it make sense to make a partial release for React 18 with only functional components support?

I think so. That's what I'm going for.