The return value of reactjs using lodash cannot deconstruct the assignment.

    const L1items = [{
       title:"",
       L2items:[
            {
                title:"",
                L3items:["",""]
            }
        ]
    }
     let temp =new Object(_.find(L1items,(item)=>{
         ....
     }));  
     //titleL2items  
     //
     let {L2items} =new Object(_.find(L1items,(item)=>{
         ....
     }));  
     //react 

Environment: the latest version of react, using create-react-app scaffolding
you can use deconstruction assignments without the data returned by lodash.? But the output of the return value of lodash is the same as that of ordinary objects.-sharp-sharp-sharp

< H2 > reflection: < / H2 >

actually loadsh works, just because the logic in the find function cannot guarantee that a return value can be found (preferably a judgment first)
when you find that this kind of code that could have passed but reports an error, you have to see if the logic of the whole code is correct. no, no, no.

Apr.08,2021

I don't see it. What's wrong with it?

Menu