Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. class Component extends React.Component {
  2. render(){
  3. return (
  4. <>
  5. <h1>Hello, {this.props.name}</h1>
  6. <h2>{this.props.loading ? 'Loading...' : this.props.children}</h2>
  7. <Clock/>
  8. </>
  9. )
  10. }
  11. }
  12.  
  13. class Clock extends React.Component {
  14. constructor(props){
  15. super(props);
  16.  
  17. this.state = {
  18. date: new Date()
  19. };
  20. }
  21.  
  22. render(){
  23. return(
  24. <h1>{this.state.date.toLocaleTimeString()}</h1>
  25. )
  26. }
  27. }
  28.  
  29.  
  30. ReactDOM.render(
  31. <Component name="Adam" loading={false}>
  32. Test
  33. </Component>,
  34. document.getElementById("app")
  35. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement