VOOZH about

URL: https://www.geeksforgeeks.org/reactjs/how-to-embed-two-components-in-one-component/

⇱ How to embed two components in one component ? - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

How to embed two components in one component ?

Last Updated : 23 Jul, 2025

React allows us to render one component inside another component. It means we can create the parent-child relationship between the 2 or more components. In the ReactJS Components, it is easy to build a complex UI of any application. We can divide the UI of the application into small components and render every component individually on the web page.

Prerequisites

Approach

To show embed components in one component in React we will create two functional components named child1 and child2 and import them in the App.js directory to render them on the UI.

Creating React Application

Step 1: Use this command to create a new react project

npx create-react-app testapp

Step 2: Move to the testapp project folder from the terminal.

cd testapp

Project Structure:

It should look like this.

👁 Image

Example: Shows two child components embeded in App.js component.

Steps to Run: To start the react app, run the below command on your terminal and verify that react app is working fine.

npm start

Output: You will see react app is started on localhost:3000 without any difficulty. Here, the App component is a parent component of the child1 and child2 components.

👁 Screenshot-from-2023-10-25-15-21-07

Comment
Article Tags: