Implementing the ask form

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:

  1. Open AskPage.tsx and import our Form and Field components:
import { Form } from './Form';
import { Field } from './Field';
  1. 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.

  1. 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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.69.54