Closed camdixon closed 2 years ago
I have the same error
Create react app is broken at the moment: https://github.com/facebook/create-react-app/issues/12278
I found the solution.
create-react-app is not updating index.js as per the new react V18
so you need to modify index.js file as follow
import React from 'react'; import {createRoot} from 'react-dom/client'; import './index.css'; import App from './App'; // import reportWebVitals from './reportWebVitals';
const container = document.getElementById('root'); const root = createRoot(container)
root.render(
)
// If you want to start measuring performance in your app, pass a function // to log results (for example: reportWebVitals(console.log)) // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals // reportWebVitals();
Here is the contents of index.js
that includes the proper render
method argument:
import React from "react";
import { createRoot } from "react-dom/client";
import "./index.css";
import App from "./App";
// import reportWebVitals from './reportWebVitals';
const container = document.getElementById("root");
const root = createRoot(container);
root.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById("root")
);
// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
// reportWebVitals();
When rerunning the create-react-app command on the website I now get a corrected installation. Good to go.
Hello everyone, and thanks for helping. Here is the information you'll need.
The command doesn't work from the website. I'm not new to react, and this is a brand new project. I only did
git init
prior to running this command in a fresh directory.Versions:
Output: