使用
({})是destructure参数和
=>()是等价的回报隐含
=> { return()}并且(仅提供一个对象的开始和功能体的开口括号之间的歧义,当你有一个多返回值一般会被使用。您可以简单地避免使用
(并将
Navlink其与箭头放在同一行
=>
const Filterlink = ({ filter, children }) => ( // <-- implicit return <Navlink to={filter === 'SHOW_ALL' ? '/' : `/${ filter }`} activeStyle={ { textDecoration: 'none', color: 'black' }} > {children} </Navlink>)相当于
const Filterlink = ({ filter, children }) => { return ( <Navlink to={filter === 'SHOW_ALL' ? '/' : `/${ filter }`} activeStyle={ { textDecoration: 'none', color: 'black' }} > {children} </Navlink> )}


