Last active
January 13, 2018 04:36
-
-
Save viniciusdacal/3c435cf572b15dba29adab44a89a707e to your computer and use it in GitHub Desktop.
This file contains 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 MyComponent = ({ type, value }) => ( | |
<div> | |
<h1>I have some content here</h1> | |
{displayData(type, value)} | |
</div> | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
nice! hahahaha This is Alur from Fb page.