From the docs:
Since version 3.22.0 hydration utilities moved into to core. If you using lower version your should import dehydrate from react-query/hydration
remove the react-query/hydration re-exports for v4, which we only kept for backwards compatibility.