October 2019
Intermediate to advanced
426 pages
11h 49m
English
As we know from the users feature, posts are also going to be global state, so we should define it in the App component.
Let's implement the posts value as global state now:
const defaultPosts = [ { title: 'React Hooks', content: 'The greatest thing since sliced bread!', author: 'Daniel Bugl' }, { title: 'Using React Fragments', content: 'Keeping the DOM tree clean!', author: 'Daniel Bugl' }]
const [ posts, setPosts ] = useState(defaultPosts)
{user && <CreatePost user={user} posts={posts} setPosts={setPosts} ...Read now
Unlock full access