I love function components and React Hooks. My first article on Medium used the useState hook, and I still think useState
is fantastic.
I don’t even mind wrapping my brain around useEffect for loading data. (Of course, we now have React Query version 3 as a fantastic alternative to useEffect
for data fetching.)
While there are reasons you might want to keep writing class components and using lifecycle methods in 2021, I don’t plan to.
Since I’m all-in on function components and React Hooks, I was surprised when I found out about a major change in React 17 that is going to affect every new component I write.
You may have missed the change, too, since the headline for React 17 was, and I’m quoting: “No New Features.”
“The React 17 release is unusual because it doesn’t add any new developer-facing features. Instead, this release is primarily focused on making it easier to upgrade React itself.” — React 17 Announcement by Dan Abramov and Rachel Nabors
I’m not even one to read release notes usually. I prefer writing new tutorials to stay “up-to-date” with dozens of technologies that are constantly changing. Writing keeps me focused on problems and use cases instead of feeling overwhelmed by the paradox of choice.
But I’m glad I read these release notes, because the change has to do with a core feature of how React works under-the-hood: the JSX transform resulting from the import React from "react"
statement.
#javascript