Interpretation introduced file creat-react-app initialization scaffold

import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';

1. import React from 'react';
Here If you do not introduce react, you can not successfully compile, even if the bottom is not used react, his main purpose is to identify jsx grammar

What is jsx grammar?

ReactDOM.render(<App />, document.getElementById('root'));  // 这里的<App/>即是jsx语法
function App() {
  return (
    <div className="App">
      Hello World
    </div>
  );
}

In fact, in return, such as App.js file we write {} in all tabs are jsx grammar, and the label is not an ordinary

2. import ReactDOM from 'react-dom';
This is used to mount the virtual dom of
such as:

ReactDOM.render(<App />, document.getElementById('root'));  // 这里的<App/>即是jsx语法

What he means is this component will be named id to mount public directory index.html
of<div id="root"></div>

3. The import './index.css'; import App from './App';
two words that is introduced into the respective components, no special

Published 14 original articles · won praise 9 · views 2169

Guess you like

Origin blog.csdn.net/weixin_44956861/article/details/95005108
Recommended