New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding better support for hooks related to time-slicing
(concurrent) ⏲️
#3760
base: main
Are you sure you want to change the base?
Adding better support for hooks related to time-slicing
(concurrent) ⏲️
#3760
Conversation
time-slicing
⏲️
time-slicing
⏲️ time-slicing
(concurrent) ⏲️
time-slicing
(concurrent) ⏲️ time-slicing
(concurrent) ⏲️
time-slicing
(concurrent) ⏲️ time-slicing
(concurrent) ⏲️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great start 🎉 Left some comments, let me know what you think.
return [false, startTransition]; | ||
const [isTransitionPending, setIsTransitionPending] = useState(false); | ||
|
||
const startTransitionFunction = (cb) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function identity will change with every render. Let's find a way to keep the reference stable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using use callback have any effect on it ?
The function identity will change with every render. Let's find a way to keep the reference stable.
compat/src/index.js
Outdated
const requestIdleCallbackPreact = | ||
(typeof self !== "undefined" && | ||
self.requestIdleCallback && | ||
self.requestIdleCallback.bind(window)) || | ||
function (cb) { | ||
return queueMicrotask(() => { | ||
cb(); | ||
}); | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if we need to bind the this
value explicitly. Maybe we can simplify this a bit?
const requestIdleCallbackPreact = | |
(typeof self !== "undefined" && | |
self.requestIdleCallback && | |
self.requestIdleCallback.bind(window)) || | |
function (cb) { | |
return queueMicrotask(() => { | |
cb(); | |
}); | |
}; | |
const requestIdleCallbackPreact = | |
typeof requestIdleCallback === 'function' | |
? requestIdleCallback | |
: queueMicrotask; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @marvinhagemeister , Currently i updated to setTimeout
since it need to be cleared in unmount. (Can you please help me with it)
🤔 |
Adding better support for concurrency⏲️
Running the concurrent task in idle period using
window.requestIdleCallback
.Extremely sorry if I made any mistakes :(