useRedactMode
Read and control redact state.
useRedactMode
Returns the current redact state and functions to enable, disable, or toggle. Must be used inside RedactProvider.
Usage
import { useRedactMode } from 'react-redact';
function AdminBar() {
const { isRedacted, mode, enable, disable, toggle, isScreenSharing } = useRedactMode();
return (
<button onClick={toggle}>
{isRedacted ? '๐' : '๐'} Demo mode ({mode})
{isScreenSharing && ' ยท recording'}
</button>
);
}Return value
| Property | Type | Description |
|---|---|---|
isRedacted | boolean | Whether redaction is currently on |
mode | 'blur' | 'mask' | 'replace' | 'secure' | 'custom' | The provider's active redaction mode |
enable | () => void | Turn redaction on |
disable | () => void | Turn redaction off |
toggle | () => void | Flip redaction state |
isScreenSharing | boolean | Whether a same-tab getDisplayMedia() capture is currently active (only meaningful when the provider's autoRedactOnScreenShare is true) |
Outside a provider, isRedacted and isScreenSharing are false, mode is 'blur', and the functions are no-ops.