Created
February 7, 2018 22:39
-
-
Save viniciusdacal/b98c7e5d197b0c897b15238c2b726eeb 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
| const handlers = { | |
| number: value => <NumberDisplay>{value}</NumberDisplay> | |
| currency: value => <CurrencyDisplay customProps value={value} /> | |
| time: value => <TimeDisplay time={value} customProps /> | |
| date: value => <DateDisplay date={value} showTime={false} /> | |
| default: value => value, | |
| }; | |
| const displayData = (type, value) => { | |
| const handler = handlers[type] || handlers.default; | |
| return handler(value); | |
| }; | |
| const DataDisplay = ({ type, value }) => ( | |
| <div> | |
| {displayData(type, value)} | |
| </div> | |
| ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment