[英]React rerender specific components
I have a controller, which renders a Table and action buttons. 我有一个控制器,它呈现一个表格和动作按钮。 The Table has Row childs, with checkboxes.
该表具有行子级,并带有复选框。 This is my render func:
这是我的渲染功能:
render() {
<div>
<Table items={this.props.items}></Table>
<Actions selectedItems={_.filter(this.props.items, i => i.selected)}
</div>
}
By checking each row, I update the item in the list with a 'selected' property. 通过检查每一行,我使用“ selected”属性更新列表中的项目。 But now, If I want to change the selected indication, I have to rerender all the container, including the table.
但是现在,如果要更改选定的指示,则必须重新渲染所有容器,包括表。 How can I do that without rendering the whole table?
如何在不呈现整个表格的情况下做到这一点? (Only render the FloatingActions)
(仅呈现FloatingActions)
this is my redux mapping: 这是我的redux映射:
Thanks. 谢谢。
You should learn to think in React. 您应该学会在React中思考。 It is ok that every component will invoke
render()
function 每个组件都可以调用
render()
函数是可以的
your component in fact will only reRender if it starts to look different. 实际上,您的组件只有在看起来不同时才会重新渲染。
if you whant to manually decide if it need to change something, you can also use componentWillReceiveProps(newProps)
and check if new props are different 如果您想手动决定是否需要更改某些内容,还可以使用
componentWillReceiveProps(newProps)
并检查新道具是否不同
it is method from life-circle like shouldComponentUpdate
这是生命周期中的方法,如
shouldComponentUpdate
but better think about containing your view state in your Store. 但最好考虑将视图状态包含在商店中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.