Advertisement
Guest User

Untitled

a guest
Apr 18th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. # React Hooks
  2. - useState
  3. ```js
  4. const [filter, setFilter] = useState('')
  5. ```
  6. - useEffect
  7. ```js
  8. useEffect(() => { return willUnmountCallback }, []) // '[]' prevents 'fn' from running on update. Executes on mount and willUnmount
  9. ```
  10. - useReducer
  11. ```js
  12. const [state, setState] = useReducer((state, newState) => ({ ...state, ...newState }), initialState)
  13. ```
  14. - useContext
  15. ```js
  16. const { logout } = useContext(GitHubContext)
  17. ```
  18.  
  19. ## Lazy and Suspense
  20. ```js
  21. React.lazy(() => <Component />) // Must have <Suspense> as HOC
  22. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement