Created
August 7, 2018 21:00
-
-
Save manoelneto/032b2fd9be9c1e4a3fd3e9693b414aaa 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, { Component } from 'react'; | |
import CurrentTime from 'components/CurrentTime'; | |
class CurrentYear extends Component { | |
render() { | |
const { time } = this.props; | |
return <div>{time.getFullYear()}</div> | |
} | |
} | |
class NextYear extends Component { | |
render() { | |
const { time } = this.props; | |
return <div>{time.getFullYear() + 1}</div> | |
} | |
} | |
class App extends Component { | |
render() { | |
return <div> | |
<CurrentTime component={({time}) => ( | |
<div> | |
Time atual: {time.toString()} | |
</div> | |
)}></CurrentTime> | |
<CurrentTime component={({time}) => ( | |
<button> | |
{time.toString()} | |
</button> | |
)}></CurrentTime> | |
<CurrentTime component={CurrentYear}></CurrentTime> | |
<CurrentTime component={(currentTimeState) => <NextYear {...currentTimeState} />}></CurrentTime> | |
</div> | |
} | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment