October 2019
Intermediate to advanced
426 pages
11h 49m
English
Next, we implement a form to allow for the creation of new posts. Here, we pass the user value as a prop to the component, as the author should always be the currently logged-in user. Then, we show the author, and provide an input field for the title, and a <textarea> element for the content of the blog post.
Let's implement the CreatePost component now:
import React from 'react'export default function CreatePost ({ user }) { return ( <form onSubmit={e => e.preventDefault()}> <div>Author: <b>{user}</b></div> <div> <label htmlFor="create-title">Title:</label> <input type="text" name="create-title" id="create-title" /> </div> <textarea /> <input ...Read now
Unlock full access