join us!
160f7c5fbbe3c0 " , to provide front-end developers with technical information and a series of basic articles. For a better user experience, please move to our official website novices (160f7c5fbbe3c8 https://xhs-rookies.com/ ) to learn and get the latest articles in time.
"Code tailor" , if you are interested in our article or want to make some suggestions, follow "Novices from Xiaohe Mountain" public account, contact us, you can also watch it on WeChat Our article. Every suggestion or approval is a great encouragement to us!
Why should we learn hooks
No destructive changes
- hooks are completely optional
hook
in the component without rewriting any code - 100% backward compatible with :
hook
does not contain any destructive changes - is now available for use :
hook
published inReact 16.8
Motivation
Hook
solves all kinds of seemingly unrelated problems that we have encountered when writing and maintaining thousands of components over the past five years. Whether you are learning React
, use it every day, or prefer to try another React
, you may be familiar with these issues.
- It is difficult to reuse state logic between components
- Complex components become difficult to understand
- Incomprehensible
class
How do we learn hooks
There are many learning materials on the React official learning website 160f7c5fbbe636 is detailed, but in terms of examples, it is more complicated and not easy to understand, and Ruan Yifeng teacher 's hooks
basic article is easy for us to get started. , But it does not give you a deeper understanding of it. There are more information on other websites, most of which are translations of the official website or partial content extraction, which can’t bring you much usefulness. data of.
And our hooks series provides simpler examples than the official website, simple tutorials that are easier to understand than online textbooks, and selected key content, so that you can have a clear understanding and proficiency
hooks
The mastery is simple to use hooks
So what are hooks
React
framework has always advocated the use of function component , but this will have a problem, sometimes when you need to usestate
or other functions such as life cycle, you can only use class component .hooks
is aReact 16.8
. It can usestate
and otherReact
features component- If function component add some
state
, now only need function component usehooks
to complete, it does not require conversion to class components - React API as long as is
use
beginning arehooks
, such asuseState
About hooks
, go to the series of articles to explore!
Preview of the next section
In the next section, we will officially start hooks
, so stay tuned!
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。