Skip to content

Commit

Permalink
fix: set correct loading state if component is already loaded. (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
abramstyle authored and gregberge committed Apr 18, 2018
1 parent 289ad67 commit 9b0cae2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/loadable.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function loadable(
this.state = {
Component: LoadableComponent.Component,
error: null,
loading: true,
loading: !LoadableComponent.Component,
}
this.mounted = false
this.loadingPromise = null
Expand Down
1 change: 1 addition & 0 deletions src/loadable.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down

0 comments on commit 9b0cae2

Please sign in to comment.