could you please tell me how to how to render list in react js .
I do like this
class First extends React.Component {
constructor (props){
super(props);
}
render() {
const data =[{"name":"test1"},{"name":"test2"}];
const listItems = data.map((d) =>
{d.name};return (
hello
);
}
}
解决方案
You can do it in two ways:
First:
render() {
const data =[{"name":"test1"},{"name":"test2"}];
const listItems = data.map((d) =>
{d.name});return (
{listItems }
);
}
Second: Directly write the map function in the return
render() {
const data =[{"name":"test1"},{"name":"test2"}];
return (
{data.map(function(d, idx){
return (
{d.name})})}
);
}