Convex with React class components
how to use convex for class component in reactjs ?
4 Replies
Using class components you can't use hooks, but you can still use the ConvexReactClient. Create it, hold a reference to it (prop-drill it or use it as a module-level global) and subscribe to a query on componentDidMount.
Then unsubscribe in componentWillUnmount
You can see the methods of the ConvexReactClient here: https://docs.convex.dev/api/classes/react.ConvexReactClient
hi
ok sir, thanks
any example sir ?
We don't have official examples of this. What version of React are you using?
nextjs latest version
However, I am implementing logic through the blockchain's TON network and it requires it to be through a class component.