Last active
September 26, 2017 14:53
-
-
Save tpetrina/8d1fe8bbc2870820224f2f4d5a068581 to your computer and use it in GitHub Desktop.
React form complication 6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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