Create a reusable hook that acquires a tracked ref on each call.
Unlike createServiceHook (which returns the raw service), this returns a ServiceRef<T> that must be released.
createServiceHook
ServiceRef<T>
The service token.
A function () => ServiceRef<T>.
() => ServiceRef<T>
1.2.0
const useRpcRef = createRefHook(Tokens.RPC);// In a component:const rpcRef = useRpcRef();await rpcRef.current.getBalance(pubkey);rpcRef.release(); Copy
const useRpcRef = createRefHook(Tokens.RPC);// In a component:const rpcRef = useRpcRef();await rpcRef.current.getBalance(pubkey);rpcRef.release();
Create a reusable hook that acquires a tracked ref on each call.
Unlike
createServiceHook(which returns the raw service), this returns aServiceRef<T>that must be released.