useSetRequest
#
DescriptionHandles setting the service request with the newRequest
only when it exists and is different than the current request.
#
Usageimport { useCallback } from 'react';import { useSetRequest } from '@springtree/eva-suite-react-hooks';import { serviceState } from 'src/store/example-service';
const Example = () => { const setRequest = useSetRequest( serviceState.request, { RequestParameter: false }, );
const handleClick = useCallback( () => setRequest( (request) => ({ RequestParameter: !request.RequestParameter, }) ), [setRequest], );
return ( <button onClick={handleClick}>Set request</button> );};
export default Example;