Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

How to downgrade from React 18 to React 17

1) From your main folder, delete: 
	a) package-lock.json file (or yarn.lock for yarn) 
	b) node_modules folder (from the terminal you can type 'rm -Rf node_modules')

2) Go to your package.json file and change these dependencies:
    FROM
    "react": "^18.0.0",
    "react-dom": "^18.0.0",
    TO
    "react": "^17.0.0",
    "react-dom": "^17.0.0",
    (You can choose the exact version you want to install)

3) Go to index.js file (src/index.js) and edit it the following way:
	a)	Change the import part of index.js:
    	FROM
	    import ReactDOM from 'react-dom/client'
		TO
		import ReactDOM from 'react-dom';
		(you just have to remove the '/client' from the import)
	
	b) Change the below part of index.js:
    	FROM 
        const root = ReactDOM.createRoot(document.getElementById('root'));
		root.render(
          <React.StrictMode>
            <App />
          </React.StrictMode>
        );

		TO
        ReactDOM.render(
          <React.StrictMode>
            <App />
          </React.StrictMode>,
          document.getElementById('root')
        );

4) Open the terminal and run 'npm install' (or 'yarn install').
 
PREVIOUS NEXT
Tagged: #How #downgrade #React #React
ADD COMMENT
Topic
Name
2+7 =