Summarized by the react cycle Tips

const listItems = numbers.map((numbers,index)=><li key={index}>{numbers}</li>)
 
const listItems = numbers.map((numbers,index)=>{
    return <li key={index}>{numbers}</li>;
});
 
Before the second wording did not write return results react reported no-unused-expressions mistake, after watching just learned, ES6 arrow function in one line of code does not write braces when the return is the default, but wrote braces, then it to manually return to return, otherwise an error

Guess you like

Origin www.cnblogs.com/llcdbk/p/11857888.html