Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
addView = async viewName => {
const { loadedComponents } = this.state;
if (loadedComponents[viewName]) return;
const View = Views[viewName];
const key = shortid.generate();
const { data } = this.props;
const component = View ? (
<View key={key} data={data} />
) : (
<Views.NullView key={key} />
);
this.setState(prevState => ({
components: [...prevState.components, component],
loadedComponents: { ...prevState.loadedComponents, [viewName]: true }
}));
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.