Skip to content

[Fresh] Support lazy() and add Suspense tests#15681

Merged
gaearon merged 3 commits intofacebook:masterfrom
gaearon:fresh-more
May 20, 2019
Merged

[Fresh] Support lazy() and add Suspense tests#15681
gaearon merged 3 commits intofacebook:masterfrom
gaearon:fresh-more

Conversation

@gaearon
Copy link
Collaborator

@gaearon gaearon commented May 20, 2019

This resolves a TODO about supporting lazy.

For now this only lets you edit a file wrapped with lazy — but not the file using lazy. That would still need some follow-up work.

Also adds test coverage for hot reloading Suspended trees.

Copy link
Contributor

@threepointone threepointone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks fine overall, shipit.

return App;
});

expect(container.textContent).toBe('Loading');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not use act() for this?
(and a couple more further down)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use how?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought act doesn't flush Suspense. I need recipes :P

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace

jest.runAllTimers();
await promise;
Scheduler.flushAll();

with

await act(async () => {
  jest.runAllTimers()
})

in general, we shouldn't have to call Scheduler.flushAll() by hand

@gaearon gaearon merged commit 5731e52 into facebook:master May 20, 2019
gaearon added a commit to gaearon/react that referenced this pull request Jun 11, 2019
* Test that state is not leaked between components

* Support lazy and add Suspense tests

* Nits
gaearon added a commit to gaearon/react that referenced this pull request Jun 19, 2019
* Test that state is not leaked between components

* Support lazy and add Suspense tests

* Nits
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants