No need to import React from 17

By Bernie FitzGerald •  Updated: 08/06/23 •  2 min read

In React 17, there is no need to add import React into each file. This is due to the advancements in the refresh mechanism in React. Rather than using the react-refresh mechanism (with react-hot-loader), React 17 now uses the Fast refresh feature.

The fast refresh feature has the following features:

Things that it doesn’t do:

I purposely made that list item as it is quite a big point. Especially as many React developers will still be dealing with applications that share class and functional components.

So it is time to say goodbye to import react:

import react from 'React';

and hello to slightly less code in your components.

Your Feedback Is Welcome

While putting together posts and articles on React and other technologies, I want to create content that my readers find useful. For this reason, I’m asking readers to join me on Twitter or Mastodon (contact details at the end of the article) to give feedback, and suggestions or even just have a general chat about software engineering. I hope to see you there!

Remember to check out my other React articles here and follow me on Twitter/X here! And now, mastodon: @bernieslearnings@mastodon.social

Thanks for reading!

Bernie FitzGerald

Keep Reading