2
I am starting my first steps with React, I would like to know why the class is not being created in React, when I run the command npx create-react-app
creates the structure below.
import React from 'react';
import logo from './logo.svg';
import './App.css';
function App() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.js</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
</div>
);
}
export default App;
My question is, why does React not create the default structure as below?
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
class App extends Component {
render(){
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code> src/App.js</code> ande save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
Learn React
</a>
</header>
</div>
);
}
}
export default App;**
I used the following commands:
npm install -g create-react-app
npx create-react-app nome-app
How can I maintain this structure?
The answer was satisfactory?
– novic