How to pass props to a child component in React

A prop can be thought of as a parameter ​in that it changes the behavior (or output) of a component. Props can be passed to any component as they are declared for any HTML tag.

svg viewer

These props can be accessed in any component’s class using the syntax below:

this.props.MyProp

Code

In the code below, we have passed a prop name and location from the parent to the child.

import React from 'react';
require('./style.css');

import ReactDOM from 'react-dom';
import App from './app.js';


New on Educative
Learn to Code
Learn any Language as a beginner
Develop a human edge in an AI powered world and learn to code with AI from our beginner friendly catalog
🏆 Leaderboard
Daily Coding Challenge
Solve a new coding challenge every day and climb the leaderboard

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved