Open tbassetto opened 4 months ago
Hi @tbassetto! 👋
I wasn't aware we had docs dependencies to this change, or that react-rx
is used outside of our own internals. Thanks for flagging! I'll let the docs team know, and see if we can add a migration section to the README to help others 😄
Here's your snippet on v3:
import {useMemo} from 'react'
import {useObservable} from 'react-rx'
const INITIAL_STATE = []
export function MyComponent() {
const docId = useFormValue(['_id'])
const documentStore = useDocumentStore();
const observable = useMemo(() =>
documentStore.listenQuery(
`*[_type == 'article' && references($currentDoc) && !(_id in path("drafts.**"))]`,
{currentDoc: docId},
{}
)
, [documentStore, docId]);
const results = useObservable(observable, INITIAL_STATE);
return (
/** Render component */
)
}
Thanks!
Not really a bug bu I have code in my studio based on https://www.sanity.io/docs/studio-react-hooks#7a5503c777f4:
Latest sanity comes with react-rx 3.0.0 which removes
useMemoObersable
but does not advice , any recommendation? The documentation should be updated too. Thanks!