It's time to implement the form to ask a question. We'll do this by taking the following steps, leveraging the Form and Field components we just created:
- Open AskPage.tsx and import our Form and Field components:
import { Form } from './Form';
import { Field } from './Field';
- Let's use these components to create a form:
<Page title="Ask a Question">
<Form submitCaption="Submit Your Question">
<Field name="title" label="Title" />
<Field name="content" label="Content" type="TextArea" />
</Form>
</Page>
So, the form will contain fields for the question title and content and the submit button will have the caption Submit Your Question.
- Let's give this a try in the running app by clicking the Ask a question button on the home page:
Our form renders just as we expect.
The generic Form and Field components really made that job pretty easy. Let's try implementing another form next.