Created
October 28, 2018 18:08
-
-
Save dance2die/4c18f793f5153a75a7770efe6c3ad31e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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