mirror of
https://github.com/gregberge/loadable-components.git
synced 2026-01-25 15:24:15 +00:00
fix: set correct loading state if component is already loaded. (#64)
This commit is contained in:
parent
289ad67e3f
commit
9b0cae2acd
@ -49,7 +49,7 @@ function loadable(
|
||||
this.state = {
|
||||
Component: LoadableComponent.Component,
|
||||
error: null,
|
||||
loading: true,
|
||||
loading: !LoadableComponent.Component,
|
||||
}
|
||||
this.mounted = false
|
||||
this.loadingPromise = null
|
||||
|
||||
@ -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 () => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user