Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dcz-switcher/7ff2d15c5f846be2f5dc5c49921bffce to your computer and use it in GitHub Desktop.
Save dcz-switcher/7ff2d15c5f846be2f5dc5c49921bffce to your computer and use it in GitHub Desktop.
Downgrade to React 17.0.2 From 18 with TypeScript Using create-react-app

Install

npx create-react-app my_app --template typescript

package.json,

Replace versions with following...

"dependencies": {
...
  "@types/react": "^17.0.39",
  "@types/react-dom": "^17.0.11",
...
  "react": "^17.0.2",
  "react-dom": "^17.0.2",

Save

Then at command line...

  npm install

src/index.tsx

Change to following...

import ReactDOM from 'react-dom';
...
ReactDOM.render(
    <App />,
  document.getElementById('root')
);

Your node version should not necessarily matter

You're good to go!

@types versions: @types/react @types/react-dom

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment