-
Notifications
You must be signed in to change notification settings - Fork 47.3k
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
Bug: Breaking change of use-subscription from 1.6.0 to 1.7.0 #24508
Comments
Oops, that's our bad. We haven't considered this change in behavior. Since it's already been out for a few weeks, it seems like changing the behavior again risks being more disruptive. So for now we're going to leave this as is and see if we get more complaints. Sorry! |
I am encountering this same error. Is there a resolution? |
Any update on this? |
Would appreciate a fix for using nanostore queries in react, much appreciated :) |
For now I'm verifying if the properties values remain unchanged. For example, to get the window dimensions: export interface WindowSizes {
width: number;
height: number;
}
const getSnapshot = ((value: WindowSizes | undefined) => () => {
if (
!value ||
value.width !== window.innerWidth ||
value.height !== window.innerHeight
) {
value = { width: window.innerWidth, height: window.innerHeight };
}
return value;
})(undefined);
const initialSizes: WindowSizes = {
width: 0,
height: 0,
};
const getServerSnapshot = () => initialSizes;
const subscribe = (
callback: (this: Window, ev: WindowEventMap['resize']) => unknown,
) => {
window.addEventListener('resize', callback);
return () => window.removeEventListener('resize', callback);
};
export const useWindowDimensions = () => {
// the 3rd parameter is optional and only needed for server side rendering
return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
}; The For more complex objects, a Not the ideal scenario, but for now this is what solved this issue for me. |
React version: 18.1.0
It looks like use-subscription has changed the internal implementation to
useSyncExternalStore
.It is causing the following error in our application:
React should bump the major version for use-subscription instead of the minor version!
The text was updated successfully, but these errors were encountered: