课程: Hands-On Introduction: React

免费学习该课程!

今天就开通帐号,24,700 门业界名师课程任您挑!

Using effects

Using effects

- [Speaker] The second most popular hook and react is the useEffect Hook. Let's take a look at what it does and why you're going to need it. UseEffect allows you to manage something we call side effects. I'm not a big fan of the term effect here but it makes sense if you think of it like this; a side effect is anything that deals with something outside of the scope of the current component. This is kind of like when you take a medicine and sometimes they can have some side effects. Basically things that the medicine didn't intend you to have. The way these used to be managed in old React was with different life cycle methods. So you had different methods for when something happened as things were being built. There was a method called componentDidMount for when the component mounted. That's basically when it appeared on the page. And then there was a different method that you called the componentDidUpdate and that…

内容