After creating a new react project using npx create-react-app new
I'm getting functional js code in App.js:
import React from 'react';
import './App.css';
//need to have a class instead of a function here:
function App() {
return (
<div className="App">
</div>
);
}
export default App;
What command do I need to create a none functional react project? If functional is better than none functional please explain why.
If you have install create-react-app
for this project, then it is come up with all the new features from react 16.8.6 (latest version of react). The latest react version come up with concept of Hooks. That is why we are getting functional component by default instead of class based component to increase the performance.
If you want class based component by default they you have to come up with older version of create-react-app
. Ref
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With