Skip to content

Instantly share code, notes, and snippets.

@cassus
Created October 25, 2014 12:24
Show Gist options
  • Save cassus/a024461b858cbb0673a9 to your computer and use it in GitHub Desktop.
Save cassus/a024461b858cbb0673a9 to your computer and use it in GitHub Desktop.
Delay component for Facebook React
/** @jsx React.DOM */
module React from 'react'
var Delay = React.createClass({
propTypes: {
by: React.PropTypes.number.isRequired,
},
getInitialState() {
return {
show: false,
}
},
componentDidMount() {
setTimeout(()=>this.setState({show: true}), this.props.by * 1000)
},
render() {
return <g>
{!this.state.show ? null :
React.Children.map(this.props.children, child=>React.addons.cloneWithProps(child, this.props))}
</g>
},
})
module.exports = Delay
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment