-
-
Save nathggns/a5fce0957e8bae9ece9a to your computer and use it in GitHub Desktop.
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 : 'LazyRender', | |
getInitialState() { return { props : this.props } }, | |
componentWillReceiveProps(newProps) { setTimeout(() => this.setState(newProps), 10) }, | |
shouldComponentUpdate(newProps, newState) { return this.state !== newState; }, | |
render() { return React.cloneElement(React.Children.only(this.props.children), this.state); } | |
}); |
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: 'LazyRender' | |
getInitialState: -> props: @props | |
componentWillReceiveProps: (newProps) -> setTimeout (=> @setState newProps), 10 | |
shouldComponentUpdate: (newProps, newState) -> @state isnt newState | |
render: -> React.cloneElement React.Children.only(@props.children), @state |
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
render: -> | |
LazyRender | |
prop1: 'thing' | |
prop2: 'another thing' | |
prop3: ['huge array', 'of', 'things'] | |
, ExpensiveComponent() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment