Lesson 2 - Build Form Profile App Using Multi-input Form Data

Building Form Profile App

Step-by-Step Procedure to Implement React Form Profile App

1. Setting Up the Project

  1. Create a New React Project: Run the following command to create a new React project:

  2. Install Bootstrap CSS: Install Bootstrap using npm:

    Import Bootstrap in the main.jsx file:

  3. Setup Folder Structure: Create a components folder inside the src directory:

2. Implement the Parent Component: AppFormProfile.jsx

The parent component manages the state for the form data and profiles, and passes the necessary props to the child component.

Code for AppFormProfile.jsx:

3. Implement the Child Component: FormProfile.jsx

The child component receives props from the parent and renders the user profile.

Code for FormProfile.jsx:

4. Styling with Bootstrap

Leverage Bootstrap classes for styling. Use d-flex, flex-row, and flex-column for layouts. Add custom styles in App.css if necessary.

5. Run the Application

Start the application using the following command:

Final Output

The app will display a form at the top for adding profiles. Below the form, profiles will be displayed in a flexbox layout with images on the left and details on the right.

Summary

This walkthrough demonstrates how to:

  1. Lift state up in the parent component.

  2. Pass props to child components.

  3. Use Bootstrap for responsive styling.

  4. Manage forms and lists dynamically in React.

Challenge : Update the component to fetch image URLs from Unsplash and allow the user to select one.

Code for Updated AppFormProfileUpdated.jsx:

3. Implement the Child Component: FormProfile.jsx

The child component receives props from the parent and renders the user profile.

Code for FormProfileUpdated.jsx

4. Styling with Bootstrap

Leverage Bootstrap classes for styling. Use d-flex, flex-row, and flex-column for layouts. Add custom styles in App.css if necessary.

5. Run the Application

Start the application using the following command:

Final Output

The app will display a form at the top for adding profiles. Below the form, profiles will be displayed in a flexbox layout with images on the left and details on the right.

Challenge : Capture Live Image from PC Camera

I want to modify App.jsx react component to capture the image data from the usb pc camera instead of using image URL.

Result

Summary

This walkthrough demonstrates how to:

  1. Lift state up in the parent component.

  2. Pass props to child components.

  3. Use Bootstrap for responsive styling.

  4. Dynamically fetch and display image options from an external API.

  5. Manage forms and lists dynamically in React.

Last updated