Functional vs Class-Components in React

David Jöch
Jul 11, 2018 · 3 min read
function Welcome(props) {
return <h1>Hello, {props.name}</h1>;
}
class Welcome extends React.Component {
render() {
return <h1>Hello, {this.props.name}</h1>;
}
}

Differences between functional and class-Components

Syntax

As functional component transpiled by Babel
The exact same component written as class component transpiled with Babel

State

Lifecycle Hooks

So why should I use functional components at all?

Conclusion

Further readings

David Jöch

Written by

Frontend Engineer 💻 Musician 🎹 www.david.joech.at

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade