Skip to content

Commit 3d75de1

Browse files
committed
Revert "Don't bother resolving and rendering lazy components"
This reverts commit a795d30. The original issue has been fix in a later version of Next.js. We also need it to get `<ExtractPlasmicQueryData />` working. Change-Id: I4cb9bce0788f8ed4a8d70c3a1a8740bda16f1f46
1 parent 4e00120 commit 3d75de1

File tree

3 files changed

+21
-22
lines changed

3 files changed

+21
-22
lines changed

src/__tests__/suspense.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ describe('renderPrepass', () => {
386386
})
387387
})
388388

389-
describe.skip('lazy components', () => {
389+
describe('lazy components', () => {
390390
it('supports resolving lazy components', () => {
391391
const value = {}
392392
const Inner = jest.fn((props) => expect(props.value).toBe(value))

src/__tests__/visitor.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ describe('visitElement', () => {
135135
expect(children.length).toBe(0)
136136
})
137137

138-
it.skip('resolves lazy components', () => {
138+
it('resolves lazy components', () => {
139139
const defer = jest.fn().mockImplementation(() => {
140140
return Promise.resolve().then(() => Noop)
141141
})

src/render/lazyComponent.js

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,14 @@ const render = (
6060
props: DefaultProps,
6161
queue: Frame[]
6262
): Node => {
63-
return null
64-
// // Component has previously been fetched successfully,
65-
// // so create the element with passed props and return it
66-
// const payload = ((type._payload || type: any): LazyComponentPayload)
67-
// if (payload._status === 1) {
68-
// return createElement(payload._result, props)
69-
// }
63+
// Component has previously been fetched successfully,
64+
// so create the element with passed props and return it
65+
const payload = ((type._payload || type: any): LazyComponentPayload)
66+
if (payload._status === 1) {
67+
return createElement(payload._result, props)
68+
}
7069

71-
// return null
70+
return null
7271
}
7372

7473
export const mount = (
@@ -78,19 +77,19 @@ export const mount = (
7877
): Node => {
7978
// If the component has not been fetched yet, suspend this component
8079
const payload = ((type._payload || type: any): LazyComponentPayload)
81-
// if (payload._status <= 0) {
82-
// queue.push({
83-
// kind: 'frame.lazy',
84-
// contextMap: getCurrentContextMap(),
85-
// contextStore: getCurrentContextStore(),
86-
// errorFrame: getCurrentErrorFrame(),
87-
// thenable: resolve(type),
88-
// props,
89-
// type
90-
// })
80+
if (payload._status <= 0) {
81+
queue.push({
82+
kind: 'frame.lazy',
83+
contextMap: getCurrentContextMap(),
84+
contextStore: getCurrentContextStore(),
85+
errorFrame: getCurrentErrorFrame(),
86+
thenable: resolve(type),
87+
props,
88+
type
89+
})
9190

92-
// return null
93-
// }
91+
return null
92+
}
9493

9594
return render(type, props, queue)
9695
}

0 commit comments

Comments
 (0)