Last active
February 20, 2020 09:55
-
-
Save guillaumewuip/82ee34713684dc7a855541d02f90d6a7 to your computer and use it in GitHub Desktop.
How to model your entities - 3
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 { Message } from ‘./Message’ | |
function renderMessage(message: Message) { | |
if (message.text) { | |
// ok we know it’s a TextMessage | |
return <TextComponent text={message.text} /> | |
} | |
if (message.url) { | |
// Problem! | |
// is it ImageMessage or AudioMessage? | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment