React Js

The World's best Software Development Study Portal

React JS Props

Props stands for properties

Props allow us to pass information to the components. Props are the global variables. We can pass props to any components

Props Example

import React, { Component } from 'react' class Welcome extends Component { constructor(props) { super(props) this.state = { message: "Welcome to my website" } } render() { return (<Content a={this.state.message} /> ) } } class Content extends React.Component{ render(){ return( <h1>{this.props.a}</h1> ) } } export default Welcome;

Output: Welcome to my website