Created
October 25, 2014 12:24
-
-
Save cassus/a024461b858cbb0673a9 to your computer and use it in GitHub Desktop.
Delay component for Facebook React
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
/** @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