The several ways to import React

With the release of React 17 we also had to change the way we import React:

Kent C. Dodds goes over all ways to import React into your code, and explains why the good ole import React from "react" no longer works and why he went for import * as React from "react"

Importing React Through the Ages →

Published by Bramus!

Bramus is a frontend web developer from Belgium, working as a Chrome Developer Relations Engineer at Google. From the moment he discovered view-source at the age of 14 (way back in 1997), he fell in love with the web and has been tinkering with it ever since (more …)

Join the Conversation


    1. That’s why it’s a breaking change + is explicitly mentioned the release notes + comes with a migration script to take care of it for you.

      The only thing that’s really changed is that the “ESModules default import” approach (third one) no longer works. Before you could use all ESModules variants, now you can’t. Note that this only affects React, other JS projects are not affected by this.

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.