React (Pass props to a stateless functional component)

Please guide. I’m back to learning react after learning JS, back in 2018.
so now i’m again blank what is what. and how should i proceed.

Hey there,

as you can see in the example, you can send data to a component:

<Welcome user='Mark' />

Here you are sending the property user with the value 'Mark'.

You are sending it, because you want the Welcome component do something with it.

To use the data, the Welcome component can use their props like so:

const Welcome = (props) => <h1>Hello, {props.user}!</h1>

props is an object that holds all the data you assigned to it above, in our case just user with the value 'Mark'.

To access the data, you can use props.user, what equals Mark.

1 Like