Home>

I found the following two types of description methods when importing React.

  • import React from'react'
  • import * as React from'react'

Do these differences in description also make a difference in what is actually imported?
Also, please let me know if there is any situation where you should use which one.

  • Answer # 1

    It seems that using default export/import in ES module is deprecated in React in the future.
    (Reference: https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html#removing-unused-react-imports
    https://github.com/facebook/react/pull/18102)

    Therefore, if you follow that convention
    import React from'react'
    not
    import * as React from'react'
    It means that it will be written as.