Skip to content

Instantly share code, notes, and snippets.

@wattlebird
Last active July 31, 2019 01:37
Show Gist options
  • Select an option

  • Save wattlebird/b19ebf85452f5f60967f653fe1d5bf15 to your computer and use it in GitHub Desktop.

Select an option

Save wattlebird/b19ebf85452f5f60967f653fe1d5bf15 to your computer and use it in GitHub Desktop.
class SomeProblematicComponent extends React.Component {
constructor(props) {
super(props)
this.state = {
data = [...props.data]
}
}
onChange = (arg) => {
this.setState(prev => {
const data = [...prev.data]
return {data: data.map(itm => {...itm, a:arg})}
}
}
render() {
// it would call onChange somewhere
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment