Hi I'd like to load multiple react components from a directory dynamically. Such that somebody only has to add a component in a directory for it to be loaded. I'm thinking something along the lines like:
import * as dynamicComponents from './dynamicComponents';
const toAdd = [] dynamicComponents.forEach(function(component){
toAdd.push( Route path={component.link} component={component.implmentation} /> })
render(<Provider store={store}>
<Router history={history}>
<Route path="/" component={Template}>
<IndexRoute component={Main} />
{toAdd}
</Route>
</Router>
</Provider>,
document.getElementById('root') );
Is this possible?
via work_account
No comments:
Post a Comment