-
Notifications
You must be signed in to change notification settings - Fork 47.9k
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
Hook equivalent for getSnapshotBeforeUpdate
#15221
Comments
@gaearon Maybe this could be moved to reactjs/rfcs for more visibility? |
It's been almost a year since this hook is marked as "Coming soon™" in the hooks FAQ, but I don't see much movement here... And this would be useful to build hooks that need to run something before the component updates (such as the example which deals with scroll positions before/after update). Is there any chance this will be looked in the near future™? I completely agree figuring out the API for this hook is a quite hard, so I'm quite sure there will be a big discussion around it. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution. |
😭 stale bot why are you like this. |
I hacked around this by using export const useLayoutAnimation = (
deps: unknown[],
easing: LayoutAnimationEasingFunction = 'easeInEaseOut',
) => {
useMemo(() => {
LayoutAnimation[easing]();
}, [...deps, easing]);
}; |
The workaround that I use is to have a component like this:
and then stick BTW I was very surprised that the cleanup function of |
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment! |
Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please create a new issue with up-to-date information. Thank you! |
Re-opening as it's still an active feature request |
What's the current thinking on this? Layout animations are impossible to perform with hooks without this. |
It's 2022 now. |
What is the thing going on? It's 2023 now. |
June 2023 What's the point of the issue if it will not be responded for more than 4 years? |
Closing as unresolvable! Thanks for the feedback! |
Why unresolvable @brainkim ? |
The current documentation says:
@sebmarkbage The "for now" implies that this will be resolved in the future, so is it actually planned? Are the docs out of date (it was planned, but now is scrapped), or did you guys close the issue by mistake? For reference, my use-case is not that rare - all I want to do is infinite scroll in both directions. I needed this exact thing in my current project in multiple places, and in previous projects. Didn't really know who to ping, sorry. |
Do you want to request a feature or report a bug?
Feature
What is the current behavior?
There is no hook based equivalent for
getSnapshotBeforeUpdate
. The docs state:What is the expected behavior?
There is a hook based equivalent for
getSnapshotBeforeUpdate
, maybe something like:This code probably is bug-ridden and not the best use of hooks but you get the idea.
I’d like to know:
Sorry, if this is being tracked somewhere and I haven’t seen it. I’m planning an intense component which will use
getSnapshotBeforeUpdate
and I’d love some guidance about the future of this lifecycle method.Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
React v16.8.0 and later. All browsers and OSes.
The text was updated successfully, but these errors were encountered: