Updates to Client Rendering APIs [ React 18 ]
Created by: MenaiAla
Is your proposal related to a problem?
It's related to Warning showing on the Browser:
ReactDOM.render is no longer supported in React 18. Use createRoot instead. Until you switch to the new API, your app will behave as if it’s running React 17. Learn more: https://reactjs.org/link/switch-to-createroot
Hardware && Software:
-
Hardware: LG gram
-
Operating System: LInux Ubuntu 22.04
-
Browser: Chrome
-
Editor: VS Code
Steps:
1 - Run create-react-app
command:
npx create-react-app react-tuto
2 - Run npm run start
command:
npm run start
Result:
The browser shows this error:
ReactDOM.render is no longer supported in React 18. Use createRoot instead. Until you switch to the new API, your app will behave as if it’s running React 17. Learn more: https://reactjs.org/link/switch-to-createroot
What I do
I change the code of index.js
to :
import React from "react";
import { createRoot } from "react-dom/client";
import App from "./App";
import "./index.css";
const container = document.getElementById("root");
const root = createRoot(container);
root.render( <App/>)
Proposal
It`s better to give developers a way to start or switch between React 18 features or just React 17.