If you are doing
console.log(props);
you can get the array with:
const arr = props.data;
or
const { data } = props;
I have finally used the function map() to resolve this issue.
It sounds like you have a React component that is receive data like this:
<MyComponent data={myArray} />
If so, then inside that component, it will receive it on the prop named data
.
function MyComponent(props) {
console.log(props.data)
return <p>{data}</p>
}
Or written with the more common destructuring assignment:
function MyComponent({data}) {
console.log(data)
return <p>{data}</p>
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.