Last active
August 29, 2015 14:23
-
-
Save eldh/5e671e2501e338064181 to your computer and use it in GitHub Desktop.
Lazy render react component
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