October 2019
Intermediate to advanced
426 pages
11h 49m
English
Finally, we are going to define and use the Reducer Hook for the posts state:
const [ posts, setPosts ] = useState(defaultPosts)
We replace it with the following Reducer Hook:
const [ posts, dispatchPosts ] = useReducer(postsReducer, defaultPosts)
{user && <CreatePost user={user} posts={posts} dispatch={dispatchPosts} />}
export default function CreatePost ({ user, posts, dispatch }) {
Read now
Unlock full access