October 2019
Intermediate to advanced
426 pages
11h 49m
English
Before learning about React context in depth, let's recap what we implemented in the earlier chapters, in order to get a feeling for the problem that contexts solve:
const [ state, dispatch ] = useReducer(appReducer, { user: '', posts: defaultPosts }) const { user, posts } = state
return ( <div style={{ padding: 8 }}> <UserBar user={user} dispatch={dispatch} /> <br /> {user && <CreatePost user={user} posts={posts} dispatch={dispatch} />} <br /> <hr /> <PostList posts={posts} /> </div> )
Read now
Unlock full access