React Component we can also use through files. just we have to create .js File e.g: App.js file then write the following code
import React from 'react';
import ReactDOM from 'react-dom';
class Name extends React.Component {
render() {
return <h2>my name is yashpal</h2>;
}
}
export default Name;
Caution
Use import React from ‘react’ as first
Use export default Name
Now to use the Component just import App.js file
import React from 'react';
import ReactDOM from 'react-dom';
import Name from './App.js';
ReactDOM.render(<Name />, document.getElementById('root'));