我现在正在学习反应.这是与代码的链接 - http://redux.js.org/docs/basics/ExampleTodoList.html
我在理解这部分代码中发生的事情时遇到了一些困难
const Link = ({ active, children, onClick }) => {
if (active) {
return <span>{children}</span>
}
return (
<a
href="#"
onClick={e => {
e.preventDefault()
onClick()
}}
>
{children}
</a>
)
}
Link.propTypes = {
active: PropTypes.bool.isRequired,
children: PropTypes.node.isRequired,
onClick: PropTypes.func.isRequired
}
Run Code Online (Sandbox Code Playgroud)
我最难理解这个片段
return (
<a
href="#"
onClick={e => {
e.preventDefault()
onClick()
}}
>
{children}
</a>
)
}
Run Code Online (Sandbox Code Playgroud)
{children}在这里意味着什么?它有什么作用?
这有什么作用?
children: PropTypes.node.isRequired,
Run Code Online (Sandbox Code Playgroud)
上述行中的节点是什么意思?