CPTRedHawk
CPTRedHawk6mo ago

Convex with React class components

how to use convex for class component in reactjs ?
4 Replies
ballingt
ballingt6mo ago
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
CPTRedHawk
CPTRedHawkOP6mo ago
hi ok sir, thanks any example sir ?
ballingt
ballingt6mo ago
We don't have official examples of this. What version of React are you using?
CPTRedHawk
CPTRedHawkOP6mo ago
nextjs latest version However, I am implementing logic through the blockchain's TON network and it requires it to be through a class component.

Did you find this page helpful?