does it replace the current API with something more complicated?

AFAIK, Facebook (FB) doesn't have a plan to phase out class based components.

I believe FB is pushing people toward writing more composable components & behaviors (hooks), creating meaning smaller components (just like Functional Programming promotes writing small functions and compose them together).

React might become more "complicated" but the architecture your site would be more manageable & readable.

 

Haven't tried it out yet, but was listening to a brief overview from Kent C. Dodds and one example that comes to mind is componentDidMount (sync) vs useEffect (async), so there appears to be performance benefits to using hooks.

I'd also guess that since everything is a function now, it would be easy to mock hooks via jest, if necessary.

Gonna get back to day 1's live stream now 😉

 

As with most their recent changes, I feel like they are veering too far towards solving complex problems that happen at Facebook scale, at the cost of making it more complex for the 99% of other use cases.

 

"Redux" has the same issue. People tend to use it early in the project creating a complicated (not complex) source code structure.

"Hooks" should be introduced gradually only when needed (but doubtful people would follow 😛)

Classic DEV Post from Apr 5

What was your win this week?

Got to all your meetings on time? Started a new project? Fixed a tricky bug?

Author and Software Consultant

Sore eyes?

dev.to now has dark mode.

Go to the "misc" section of your settings and select night theme ❤️