Created
March 2, 2017 11:12
-
-
Save Ami777/d48ae8207ff7543f763ff6d1813a28b6 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
import React from 'react'; | |
import ReactDOM from 'react-dom'; | |
document.addEventListener('DOMContentLoaded', function(){ | |
class ShowInfo extends React.Component { | |
render() { | |
return <h1>{ this.props.info }</h1>; | |
} | |
} | |
class PropsToState extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
text: this.props.text, | |
}; | |
} | |
componentDidMount(){ | |
this.intervalId = setInterval(() => { | |
this.setState({ | |
text : this.state.text + '.', | |
}); | |
}, 1000); | |
} | |
componentWillUnmount(){ | |
clearInterval( this.intervalId ); | |
} | |
render() { | |
return <ShowInfo info={this.state.text}/> | |
} | |
} | |
class App extends React.Component { | |
render(){ | |
return <PropsToState text="Sialalal" />; | |
} | |
} | |
ReactDOM.render( | |
<App />, | |
document.getElementById('app') | |
); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment