Related Tags

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:



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

import React from 'react';

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

View all Courses
Related Courses
Related Courses
View all Courses

Keep Exploring