Using the required

Recently, two projects in a row began to write react hooks. During the process of writing, I also encountered many bugs. Sometimes, IN order to solve the bugs, I also found many answers on the Internet. Sometimes I get tired of it and wonder if I should have used React hooks, it would have been more efficient to do it the way it was. Finally stick to it, summarized as follows:

  • Writing is definitely to write – if you still use the original, you may have been stuck on your laurels, one step backwards, the next will follow.
  • Before writing, be sure to read the document at least once, both in Chinese and English. If English is not good, you can learn to read both in Chinese and English. Chinese documents and English documents
  • After reading the document, you can write some demo first
  • Add react-hooks to eslint -eslint-plugin-react-retts.eslintrc as follows:
{
  "plugins": ["react-hooks"]."rules": {
    "react-hooks/rules-of-hooks": "error"."react-hooks/exhaustive-deps": "error"}}Copy the code

React-hooks/Enumn-deps at least warn, but also error It is recommended that new projects be configured with “error” and historical projects with “WARN”.

Reading the article is recommended before use

  • React Hooks Complete tutorial
  • The complete useEffect guide is highly recommended
  • Function Component Primer
  • How ReactFiber works in concurrent mode