Skip to content

Instantly share code, notes, and snippets.

@tpetrina
Last active September 26, 2017 14:53
Show Gist options
  • Save tpetrina/8d1fe8bbc2870820224f2f4d5a068581 to your computer and use it in GitHub Desktop.
Save tpetrina/8d1fe8bbc2870820224f2f4d5a068581 to your computer and use it in GitHub Desktop.
React form complication 6
componentWillMount() {
let proxy = {}
for (var i in this.state) {
if (typeof this.state[i] === "function") {
this.foos[i] = state[i].bind(null, proxy)
} else {
let key = i
Object.defineProperty(proxy, key, {
set: value => this.setState({ [key]: value }),
get: () => this.state[key]
})
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment