useController()
function useController(): Controller;
Provides access to Controller from React, which can be used for imperative control over the cache. For instance fetch, invalidate, and setResponse
import { useController } from '@rest-hooks/react';
function MyComponent({ id }) {
const ctrl = useController();
const handleRefresh = useCallback(
async e => {
await ctrl.fetch(MyResource.get, { id });
},
[fetch, id],
);
const handleSuspend = useCallback(
async e => {
await ctrl.invalidate(MyResource.get, { id });
},
[invalidate, id],
);
const handleLogout = useCallback(
async e => {
ctrl.resetEntireStore();
},
[resetEntireStore],
);
}