Reactjs Props


Free Online Tutorials on JavaScript, Node.js, React.js, PHP, JAVA, Python, HTML, GraphQl, TypeScript, MEAN, MERN Stack, etc.

Props in React.js

Props are inputs to components. They are single values or objects containing a set of values that are passed to components on creation using a naming convention similar to HTML-tag attributes. They are data passed down from a parent component to a child component.

  • In React Js we use props to send data to the components.
  • In React Js every component is treated as a pure javascript function.
  • In React Js props are equivalent to parameters of a pure javascript function.
  • Props are immutable. Because these are developed in the concept of pure functions. In pure functions we cannot change the data of parameters. So, also cannot change the data of a prop in React Js.

Passing and Accessing props in React Js Components:

We can pass props to any component as we declare attributes for any HTML tag.

We can access any props inside from the component's class to which the props is passed.


//In our we can get prop using props name like below:
import React, { Component } from 'react';

class App extends Component {
  render() {
    const message = 'Welcome to React Js Tutorial';

    return (
); } } class Message extends Component { render() { return


; } } export default App;
Previous Page