Uncaught Error: Missing Subscribe #266
Unanswered
SerkanSipahi
asked this question in
Q&A
Replies: 1 comment 3 replies
-
Hey, there are a few issues on your code:
The concept behind react-rxjs is that you can build a reactive state that's mostly independent from React. It seems your case is a bit special because I guess Probably the best implementation for that would be to just subscribe to the observable yourself: export function useWatchSelector<Element extends HTMLElement>(
selector: string,
startWithInterval = 0,
interval = 250,
context: Document | HTMLElement = document,
) {
const [watchElement, setWatchElement] = useState<Element | null>(null);
useEffect(() => {
const subscription = watchSelector<Element>(selector, context, interval, startWithInterval)
.subscribe(element => setWatchElement(watchSelectorValue));
return () => subscription.unsubscribe();
}, [selector, context, interval, startWithInterval]);
return watchElement;
} But if I were to use this with react-rxjs, I would probably have to drop all the parameters, leaving it as: const [useVideoElement] = bind( // Element | null
watchSelector<Element>('video', document, 250, 0),
null
)
export function App() {
const element = useVideoElement();
return <div>{element ? 'Found' : 'notFound'}</div>;;
} A few things worth of note:
|
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Unfortunately, I don't know what to do because I am very new to the React world and have only worked with Angular until now. Unfortunately, I cannot assign this error. What does "Missing Subscribe" mean? Do I have to subscribe to it myself? If so, what steps are missing here? I have orientated myself on the tests and also on the React page how to build custom hooks.
Sources:
https://github.com/re-rxjs/react-rxjs/blob/main/packages/core/src/bind/connectObservable.test.tsx
https://react-rxjs.org/docs/api/core/bind
https://reactjs.org/docs/hooks-custom.html
Where are my misconceptions of using of
react-rxjs
?log://error
Error Missing Subscribe! Call Stack gv vendor.js:1142:15 mountSyncExternalStore vendor.js:23762:20 Object.useSyncExternalStore vendor.js:24701:14 useSyncExternalStore vendor.js:40731:21 useStateObservable vendor.js:1175:101 useStaticObservable vendor.js:1190:37 App main.js:102:30 renderWithHooks vendor.js:23268:18 mountIndeterminateComponent vendor.js:27960:13 beginWork vendor.js:29464:16
file://main.tsx
file://app.tsx
file:// use-watch-selector.ts
Beta Was this translation helpful? Give feedback.
All reactions