Created
October 14, 2014 08:16
-
-
Save mbektimirov/b1b6525e64d6fae92048 to your computer and use it in GitHub Desktop.
React: state from props
This file contains hidden or 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
module.exports = React.createClass | |
displayName: 'Switcher' | |
getInitialState: (props) -> | |
props ||= @props | |
checked: props.checked | |
componentWillReceiveProps: (newProps, oldProps) -> | |
@setState @getInitialState(newProps) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment