Created
September 15, 2022 18:10
-
-
Save newerton/547d9b09cebbac684e3e7a82fecd4b9b to your computer and use it in GitHub Desktop.
Apply Interface segregation principle (ISP)
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
type Props = { | |
items: Array<Video | LiveStream> | |
} | |
const VideoList = ({ items }) => { | |
return ( | |
<ul> | |
{items.map(item => { | |
if ('coverUrl' in item) { | |
// it's a video | |
return <Thumbnail video={item} /> | |
} else { | |
// it's a live stream, but what can we do with it? | |
} | |
})} | |
</ul> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment