我尝试使用 map 函数在 react-hooks useState 中循环我的列表数据,但我遇到了一个错误“TypeError:无法读取未定义的属性‘map’”
//1.Initial declaration
const App = props=> {
const [state, changeState]= useState ({
name:"",
eventTitle:"",
details:"",
objdata:{},
list:[],
toggleIndex:"",
editName: "",
editEventTitle: "",
editDetails: "",
editObj: {}
});
//2.logic comes here
//3.tried using map
{(state.list.map((data,id)=>{
console.log ('loop data',data)
}))}
Run Code Online (Sandbox Code Playgroud)