If 'React' is the default export from 'react', Why can't we use some other name instead of 'React' If 'React' is the default export from 'react', Why can't we use some other name instead of 'React' reactjs reactjs

If 'React' is the default export from 'react', Why can't we use some other name instead of 'React'


You can import React that way, but if you're using JSX, you also need to update your configuration to tell the transpiler that you're using that the "builder" function is no longer React.createElement, but is instead Somename.createElement. (If you're using Babel, you do that with the pragma directive.) That's because, as it says in the React documentation, this:

const element = (  <h1 className="greeting">    Hello, world!  </h1>);

Is transpiled to:

const element = React.createElement(  'h1',  {className: 'greeting'},  'Hello, world!');

...so React (or whatever name you change it to in the configuration) must be in scope. Other than that, it's fine.