The difference between whether components should be imported in brackets or without them is how they are export .
There are two types of export
- Default Export
- Named Export
A component can have one default export and zero or more named exports
If the component is the default export, you need to import it without parentheses. for example
export default App;
Import it's like
import App from './path/to/App';
Named exports can be either
export const A = 25;
or
export {MyComponent};
You can import it as
import {A} from './path/to/A';
or
import {A as SomeName} from './path/to/A';
If your component has one default export and multiple named exports, you can even mix them during import
import App, {A as SomeName} from './path/to/file';
Similarly, in the case of react and react-dom , React and ReactDOM is default exports by Component named export react render react-dom default exports , respectively, while, for example, Component is named export in react and render is named export in react-dom . That is why you can do
import ReactDOM from 'react-dom';
and then use
ReactDOM.render()
or use as indicated in your question.
Shubham khatri
source share