React 怎么样去根据props 不同,加载的资源不同

#1

React 怎么样去根据props 不同,加载的资源不同

#2

使用
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 ;
}
这种方式可好?