Closed Guria closed 8 years ago
Just to bringing in a different perspective :-)
const components = {
'inbox': Inbox,
'calendar': Calendar,
'todo': Todos
};
@Cerebral({
activeModule: ['activeModule']
})
class App extends Component {
render () {
const Component = components[this.props.activeModule];
return (
<div>
<Navbar />
<Component />
</div>
);
}
}
Thats a lot more better. Great snippet for the docs, in fact.
Would the active module be defined by the url? Can you store multiple modules in the central state?
You could use something like lodash' get command for some sort of nested version:
const components = {
'contact': {
'list': ListComponent,
'detail': DetailComponent
}
};
And retrieve like so:
const Component = _.get(components, ["contact", "list"]);
I will close this as we are exploring a cerebral-modules
concept. Look out for it in near future :-)
Just dumping some ideas