E2EHIRING Logo
Jobs
Jobs
courses
Courses
mentorship
Mentorship
more
Moredropdown
E2EHIRING Logo
more
Jobs
Jobs
courses
Courses
mentorship
Mentorship
HomeSepratorIconBlogsSepratorIconReact (how to use props)SepratorIcon

React (how to use props)

Han SoloAnbarasan Murugan
calendar27 Jun 2022
poster

React props:

  • Props Stands for properties.
  • Props are arguments passed into React components.
  • Props are passed to components via HTML attributes.

Pass Data:

  • Props are also how you pass data from one component to another, as parameters.

Example:

import React from 'react';
import ReactDOM from 'react-dom/client';

function Car(props) {
  return <h2>I am a { props.brand }!</h2>;
}

function Garage() {
  return (
    <>
        <h1>Who lives in my garage?</h1>
        <Car brand="Ford" />
    </>
  );
}

const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<Garage />);
Output:
Who lives in my Garage?
I am a Ford!

Recent Posts

Datatypes and Operator

Datatypes and Operator

Mastering Unit Testing in Angular: A Comprehensive Guide

Mastering Unit Testing in Angular: A Comprehensive Guide

New features in VueJS 3.3

New features in VueJS 3.3

The Art of Writing Documentation for Your Code

The Art of Writing Documentation for Your Code

How MuleSoft Supports Microservices Architecture

How MuleSoft Supports Microservices Architecture

copycopycopycopy

Han Solo

Recent Posts

Datatypes and Operator

Datatypes and Operator

Mastering Unit Testing in Angular: A Comprehensive Guide

Mastering Unit Testing in Angular: A Comprehensive Guide

New features in VueJS 3.3

New features in VueJS 3.3

The Art of Writing Documentation for Your Code

The Art of Writing Documentation for Your Code

How MuleSoft Supports Microservices Architecture

How MuleSoft Supports Microservices Architecture