Created
January 15, 2021 06:06
-
-
Save JimmyLv/a4823d6de34e6f88852f9deeffdfe84d to your computer and use it in GitHub Desktop.
Created with Copy to Gist
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 React from 'react'; | |
| import { PhotoStory, VideoStory } from './stories'; | |
| const components = { | |
| photo: PhotoStory, | |
| video: VideoStory | |
| }; | |
| function Story(props) { | |
| // Correct! JSX type can be a capitalized variable. | |
| const SpecificStory = components[props.storyType]; | |
| return <SpecificStory story={props.story} />; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment