Skip to content

Instantly share code, notes, and snippets.

@JimmyLv
Created January 15, 2021 06:06
Show Gist options
  • Select an option

  • Save JimmyLv/a4823d6de34e6f88852f9deeffdfe84d to your computer and use it in GitHub Desktop.

Select an option

Save JimmyLv/a4823d6de34e6f88852f9deeffdfe84d to your computer and use it in GitHub Desktop.
Created with Copy to Gist
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