Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # React Hooks
- - useState
- ```js
- const [filter, setFilter] = useState('')
- ```
- - useEffect
- ```js
- useEffect(() => { return willUnmountCallback }, []) // '[]' prevents 'fn' from running on update. Executes on mount and willUnmount
- ```
- - useReducer
- ```js
- const [state, setState] = useReducer((state, newState) => ({ ...state, ...newState }), initialState)
- ```
- - useContext
- ```js
- const { logout } = useContext(GitHubContext)
- ```
- ## Lazy and Suspense
- ```js
- React.lazy(() => <Component />) // Must have <Suspense> as HOC
- ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement