New ROOT API
Before
import ReactDOM from'react-dom';
import App from'App';
ReactDOM.render(<App />, document.getElementById('root'));
new
import ReactDOM from'react-dom';
import App from'App';
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<App />);
By switching to the new Root API, you will automatically get the new out-of-the-box features brought by React 18!
how to install?
Use the @alpha tag to install React 18 immediately
$ npm install react@alpha react-dom@alpha
It will take several months for Alpha to reach Beta, after which it will take more time to fully stabilize
Post comment 取消回复