-
Notifications
You must be signed in to change notification settings - Fork 25
props maybe not immutable #10
Comments
@georgebbbb technically onChange is a property of your Component and should really be something similar to this: const props = {
value: 123,
onChange: this.handleChange.bind(this),
}
<My {...Immutable.fromJS(props)} /> Update: this solution should not work since we are creating a new reference to |
Thank you |
Yeah I can see that my example above doesn't make sense. I'll take a look this weekend and add a test case to cover this issue. Feel free to do the same. I think there is an obvious solution, I just need a test to flush it out. |
ok,thank you very much |
@georgebbbb I still haven't added any tests for this issue. But, there may be a quick fix for you. Instead of calling bind() every render, try calling bind once, in the constructor of your Component. This should keep the onChange() handler referentially equal in child components. class App extends React.Component {
constructor() {
super();
this.handleChange = this.handleChange.bind(this);
}
render() {
return (
<My value={Immutable.fromJS({value:123}) } onChange={this.handleChange}></My>
);
}
handleChange() {
//...
}
} Let me know if this fixes the issue. |
@georgebbbb were you able to confirm the above solved the issue? |
examples
this component's props.onChange isn't immutable
so
may be miss compare mutable data like
onChang
The text was updated successfully, but these errors were encountered: