I have a functional component like this:
const myFunction = () => {
let array = [];
.....
return array; // The function return an array
}
...
return (
<MyComponent data={myFunction()} />
)
I would like to transfer an array to “MyComponent” but the “props.data” value always return an empty array:
class MyComponent extends React.Component {
constructor(props) {
super(props);
console.log(props.data);
}
}
Do you know how can I send data to my component class ?