Storing data from a constant as props

Asked

Viewed 28 times

1

I have the following constant:

const: lista = [{
 id: 1,
 poke: 'Pikachu',
 desc: 'Pokemon do tipo elétrico',
}, {
 id: 2,
 poke: 'Squirtle',
 desc: 'Pokemon do tipo água',
}]

And I need a component to receive this data as props, but I don’t know the syntax to receive this data as props in another component.

1 answer

1


You pass it as a property of your component:

<SeuComponente lista={lista} />

There in the component "Your component" you will be able to call it via props:

this.props.lista

And then it will have the value you spent previously.

I hope I’ve helped.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.