ฉันพยายามเรียกใช้คลาส Buttons โดยส่งค่าไปยังวิธีการมองเห็นFilter(value){...} และได้รับข้อผิดพลาด
Warning: _renderNewRootComponent(): Render methods should be a pure function of props and state;
triggering nested component updates from render is not allowed.
If necessary, trigger nested updates in componentDidUpdate.
Check the render method of Buttons.
รหัสของฉันมีดังต่อไปนี้:
class Buttons extends React.Component {
visibilityFilter(value){
let action = {type: 'set_visibility_filter',payload: {name: value, on: true}};
store.dispatch(action);
};
render(){
return(
<div className="container-fluid">
<div className="row">
<div className="col-lg-4 col-md-4 col-sm-4 col-xs-0">
<buttom type="button" className="m-t-1-em w-100 btn btn-info" onClick={this.visibilityFilter('favorite')} >Favorite</buttom>
</div>
</div>
</div>
);
};
};
เกิดอะไรขึ้นและจะส่งผ่านค่าไปยังเมธอดได้อย่างไร?