课程: Hands-On Introduction: React

免费学习该课程!

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

Component Hooks

Component Hooks

- [Instructor] Technically just writing components through functions makes a lot of sense but in reality that notation isn't what makes things hooks. So let's take a look at components with hooks. Hooks are special functions that allowed your code to hook into React's objects. They give you access to things like state which is how we store data in React. We'll take a look at that in just a minute when we learn about the most common hook, the use state hook. Now they also give you access to life cycle methods. We'll learn about those a little bit later. These are methods that are called when certain events happen in your application. So let's take a look at our project and we'll start by taking the components that we're using and externalizing them, which is a better practice. You don't really want to put all your components in the same file like we've done here. They really become useful when you take 'em out of a project…

内容