Pass Data from One Component to Another in React

This is an example of passing data from one component to another component in React.

Let this will be the component where we pass data through props from another component:

import React from 'react';

function Second(props) {
    return(
      <p> {props.data} </p>
    );
}

export default Second;

The following will be another component from which we will pass data to the component above:

import React from 'react'
import First from './Second';

const First = () => {
const data = "Data from first component";
    return(
        <div>
          <Second data={data}/>
        </div>
    );
}

export default First;