fix: set correct loading state if component is already loaded. (#64)

This commit is contained in:
Abram 2018-04-18 23:27:26 +08:00 committed by Greg Bergé
parent 289ad67e3f
commit 9b0cae2acd
2 changed files with 2 additions and 1 deletions

View File

@ -49,7 +49,7 @@ function loadable(
this.state = {
Component: LoadableComponent.Component,
error: null,
loading: true,
loading: !LoadableComponent.Component,
}
this.mounted = false
this.loadingPromise = null

View File

@ -41,6 +41,7 @@ describe('#loadable', () => {
await Loadable.load()
const wrapper = mount(<Loadable />)
expect(wrapper.contains(<Dummy />)).toBe(true)
expect(wrapper.state().loading).toBe(false)
})
it('should do nothing if component is not mounted', async () => {