Skip to content

Commit

Permalink
Fix loading showing before pastDelay (#6628)
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk committed Mar 12, 2019
1 parent 8cf6ef5 commit e2944c0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion packages/next-server/lib/dynamic.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ export default function dynamic (dynamicOptions, options) {
let loadableFn = Loadable
let loadableOptions = {
// A loading component is not required, so we default it
loading: ({ error, isLoading }) => {
loading: ({ error, isLoading, pastDelay }) => {
if (!pastDelay) return null
if (process.env.NODE_ENV === 'development') {
if (isLoading) {
return <DefaultLoading />
Expand Down
4 changes: 2 additions & 2 deletions test/integration/basic/test/dynamic.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ export default (context, render) => {
})
})
describe('ssr:false option', () => {
it('should render loading on the server side', async () => {
it('should not render loading on the server side', async () => {
const $ = await get$('/dynamic/no-ssr')
expect($('body').html()).not.toContain('"dynamicIds"')
expect($('p').text()).toBe('loading...')
expect($('body').text()).not.toMatch('loading...')
})

it('should render the component on client side', async () => {
Expand Down
4 changes: 2 additions & 2 deletions test/integration/production/test/dynamic.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ export default (context, render) => {
})
})
describe('ssr:false option', () => {
it('should render loading on the server side', async () => {
it('should not render loading on the server side', async () => {
const $ = await get$('/dynamic/no-ssr')
expect($('p').text()).toBe('loading...')
expect($('body').text()).not.toMatch('loading...')
})

it('should render the component on client side', async () => {
Expand Down

0 comments on commit e2944c0

Please sign in to comment.