marcobonomo.dev

Navigate back to the homepage

Why I'm in love with function components

Marco Bonomo
May 11th, 2019 · 1 min read

As I told you in my first post, I’m learning React again from scratch. I made a little app in 2015 with React and Firebase and React components were using React.createClass() at the time. The jump didn’t seem so high at the time when I started exporimenting with VueJS. Four years have passed and the little town I left seems like a Metropolis, it’s not all gold that glitters, but something really catch my eye: Function components. The beautiful, clean, simple way to declare components like a function, with props and children as parameters. Let’s see an example:

1function Welcome(props) {
2 return <h1>Hello, {props.name}</h1>;
3}

To me this is beatiful, simple but powerful. With the release of Hooks in React 16.8 you don’t need a class anymore so function components are a wonderful way to write an application: just write functions!

Hooks let you use state and other React features without writing a class. You can also build your own Hooks to share reusable stateful logic between components.

Dan Abramov - React v16.8: The One With Hooks

More articles from marcobonomo.dev

Starting with React (again)

So why am I going with React now? To keep myself off-balance. To challenge myself, learning something new.

April 30th, 2019 · 1 min read
© 2019 marcobonomo.dev
Link to $twitterLink to $githubLink to $instagramLink to $linkedin