Skip to content

Remove checking "resolving" in needToResolveOnBrowser #99

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/__tests__/integration.test.js
Original file line number Diff line number Diff line change
@@ -193,6 +193,28 @@ describe('integration tests', () => {
const wrapper = mount(app)
expect(wrapper.html()).toContain('Loading...')
})

it('renders the LoadingComponent without bootstrapper', async () => {
const AsyncComponent = asyncComponent({
resolve: () =>
new Promise(resolve =>
setTimeout(() => resolve(() => <div>foo</div>), 100),
),
LoadingComponent,
})
const Comp = ({ compKey }) => (
<div>{compKey ? <AsyncComponent key={compKey} /> : null}</div>
)
const wrapper = mount(<Comp compKey="1" />)
expect(wrapper.html()).toContain('Loading...')
// Unmount the component immediately
wrapper.setProps({
compKey: '2',
})
expect(wrapper.html()).toContain('Loading...')
await new Promise(resolve => setTimeout(resolve, 150))
expect(wrapper.html()).not.toContain('Loading...')
})
})

describe('server rendering', () => {
1 change: 0 additions & 1 deletion src/asyncComponent.js
Original file line number Diff line number Diff line change
@@ -44,7 +44,6 @@ export default function asyncComponent(config) {
const needToResolveOnBrowser = () =>
state.module == null &&
state.error == null &&
!state.resolving &&
typeof window !== 'undefined'

// Takes the given module and if it has a ".default" the ".default" will