I want to use npx create-react-app .
to generate a new react app but I want the version to be changed so that it generates with class structures and not the new hook structure.
I've tried changing the version of react
and React-DOM
in the package.json and running npm i
but it doesn't overwrite the old app.
If I remember correctly, the boilerplate App.js created doesn't use hooks at all, but it does use functional components. Just replace it to something of the likes:
import React from 'react';
function App() {
return (
< ...this will go inside the render() method... >
);
}
import React, { Component } from 'react';
class App extends Component {
render() {
return (< ... >)
}
}
Don't forget the { Component }
import, or alternatively use extends React.Component
.