Skip to main content
Version: 6.3

useController()

function useController(): Controller;

Provides access to Controller

import { useController } from 'rest-hooks';

function MyComponent({ id }) {
const { fetch, invalidate, resetEntireStore } = useController();

const handleRefresh = useCallback(
async e => {
await fetch(MyResource.detail(), { id });
},
[fetch, id],
);

const handleSuspend = useCallback(
async e => {
await invalidate(MyResource.detail(), { id });
},
[invalidate, id],
);

const handleLogout = useCallback(
async e => {
resetEntireStore();
},
[resetEntireStore],
);
}