2

Today i updated my node, npm and create-react-app version and now everytime i create a new app, the App.js doesn't come with Component, its just creates a function as you can see below.

function App() {
  return (
    <div className="App">
    </div>
  );
}

before it was

class App extends Component {
  render() {
    return <div />;
  }
}

Did things changed in the 3.0.0 create-react-app version?

Nodejs version: v10.15.3

Npm version: 6.4.1

1 Answer 1

6

That App function is a valid React component. It is a functional component as opposed to a class component in your second example.

You are correct, this change was made in v3.0.0: change class component to function component

Sign up to request clarification or add additional context in comments.

2 Comments

I should use functional component or keep using statefull as before?
It's usually a personal choice. If I want to create a stateless component, I will write a functional component and If I have to maintain component level state, I will either write a class component or a functional component with useState hook.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.