【发布时间】:2017-01-06 20:58:06
【问题描述】:
我在这里查看一个 React/Redux 示例:
http://redux.js.org/docs/basics/ExampleTodoList.html
请注意以下内容永远不会完成:
const CommentForm = React.createClass({
render: function() {
return (
<div className="commentForm">
</div>
);
}
});
使用箭头函数代替类。
const Todo = ({ onClick, completed, text }) => (
<li
onClick={onClick}
style={{
textDecoration: completed ? 'line-through' : 'none'
}}
>
{text}
</li>
)
为什么会这样,什么时候必须实现 render 方法?
【问题讨论】:
-
谷歌搜索“无状态组件”
标签: reactjs