SHARE
TWEET

Untitled

a guest Jun 19th, 2019 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. )
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top