Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
These changes introduce a global
autoStart
configuration option, that when enabled, will schedule and manage lazy component loaders automatically. This ultimately removes the need to haveuseLazyPhase
and will close #67.Changes
autoStart
global configuration, and associated documentationuseScheduler
hook and associated tests, which is used in the client lazy component@testing-library/react-hooks
to test the schedulerautoStart
configuration in the client lazy component, by scheduling the deferred task inside of auseLayoutEffect
(more discussion and rationale here: In StrictMode, the useState() initializer function is called twice, but one of the results is discarded facebook/react#20090 (comment)), and add corresponding testsautoStart
in root andLazyWait
integration testsNotes
autoStart
handling is performed in the component render, which ensures that the behaviour is consistent in the case where alazy*
factory is imported and evaluated beforeinit
. So long as theinit
is called before React render, this should be obey the rule of hooks and work as expected.