Fix bugs in lazy and stabilize it#1900
Conversation
People can be co-author:
|
🦋 Changeset detectedLatest commit: 1733815 The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| } | ||
|
|
||
| const loadNoReturn = () => load().then(noop) | ||
| const loadNoReturn = Object.assign(() => load().then(noop), { toString: () => load.toString() }) |
There was a problem hiding this comment.
We check the loading state of a component using Function.toString(), but it always returns the same value when the function is set like load().then(noop).
| const reloadCount = parseInt(storedValue, 10) | ||
| if (Number.isNaN(reloadCount)) reloadStorage.removeItem(storageKey) | ||
| currentRetryCount = reloadCount | ||
| if (Number.isNaN(reloadCount)) { |
There was a problem hiding this comment.
NaN was silently killing lazy
|
Size Change: -147 B (-0.24%) Total Size: 59.9 kB
ℹ️ View Unchanged
|
| } | ||
|
|
||
| const loadNoReturn = () => load().then(noop) | ||
| const loadNoReturn = Object.assign(() => load().then(noop), { toString: () => load.toString() }) |
There was a problem hiding this comment.
| const loadNoReturn = Object.assign(() => load().then(noop), { toString: () => load.toString() }) | |
| const loadNoReturn = load |
Then How about this? We can just pass load directly too.
There was a problem hiding this comment.
load actually returns a value, so it'll break type system.
There was a problem hiding this comment.
it'll break type system.
But it's not BREAKING CHANGE because lazy was an experimental interface yet. so I want you just care about which one is better implementation
There was a problem hiding this comment.
I just simplified it!
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1900 +/- ##
=======================================
Coverage 94.04% 94.05%
=======================================
Files 41 41
Lines 655 656 +1
Branches 166 167 +1
=======================================
+ Hits 616 617 +1
Misses 36 36
Partials 3 3
🚀 New features to boost your workflow:
|
60e60ee to
1733815
Compare
Overview
Fixed several bugs in lazy and removed the
@experimentaltag to mark it as stable.Additional features I'm currently working on:
These are considered feature additions rather than stabilization work, so they will be handled in separate PRs.
PR Checklist