Обложка канала

TheFrontEnd🔥

10926 @thefrontend

📝 Articles🗞 News 👓Tutorials 🤔 UI/UX thoughts ‌

TheFrontEnd🔥

5 лет назад
Открыть в
Hooks

Thanks god they came in. I'm one of those people who always like to break components apart to make it reusable and small.

Quite often I noticed that functional components still want some state to be togglable. This used to be a pain as you either have to transform to class or play football with passing stuff from and to child / parent components.

And now it's all about

const Child = ({prop1, prop2}) => {
//useEffect

return smth
}

As a benefit setLoading(false) is much more concise than
this.setState({ isLoading: false})

https://link.medium.com/GjcKRVVlxcb