Testing out React (v16.8.0-alpha) Latest API
React Hooks
Take note that React Hooks are still in Alpha.
React Hooks are available for functional component which are a "replacement" for react state in class component.
Using useState()
you can create an array, where the first item in the array is the state, and the second item is a function to set the state.
Read more about React useState()
What makes hook really awesome is useEffect()
function, because it replace 3 lifecycle hooks of react class component (componentDidMount
, componentWillUnmount()
& componentDidUpdate
)
Read more about React useEffect()
Ultimately, with React Hooks, you are able to write even less codes and in a more functional approach.
Live version
Live version of the site is at https://superoo7.github.io/react-16.8.0-alpha/
The source code is on GitHub, which includes another few latest API (React.Suspense, Context API and Hooks)