How to use create-react-app with an older React version?

If you’re here because of react v18, and you want to go down to the previous non-change breaking version, here’s what i did:

in your package.json replace:

"react": "^18.0.0"
"react-dom": "^18.0.0"

with

"react": "^17.0.2"
"react-dom": "^17.0.2"

Then go to your entry file index.js
At the top, replace:

import ReactDOM from 'react-dom/client'

with

import ReactDOM from 'react-dom';

Still in your index.js file, replace:

const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
  <React.StrictMode>
    <App />
  </React.StrictMode>
);

with

ReactDOM.render(
  <React.StrictMode>
    <App />
  </React.StrictMode>,
  document.getElementById('root')
);
  • Delete your node_modules and run yarn install
  • After installation, run yarn start
  • Enjoy

Leave a Comment