Created
February 20, 2020 07:58
-
-
Save guillaumewuip/d6c1435da51beb8131b25a3cf599d89f to your computer and use it in GitHub Desktop.
How to model your entities - 10
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 { TextMessage, ImageMessage, AudioMessage, fold } from ‘./Message’; | |
const renderMessage = fold( | |
(textMessage: TextMessage) => <TextComponent text={message.text} />), | |
(imageMessage: ImageMessage) => <ImageComponent url={message.url} description={message.description} />, | |
(audioMessage: AudioMessage) => <AudioComponent url={message.url} description={message.description} /> | |
) | |
// Somewhere in a component far, far away... | |
return ( | |
renderMessage(message) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment