StateManagerVisibility
This is not a reliable way to hide sensitive values.
While this works for React Dev Tools, the built-in memory inspector in most browsers will still be able to show the value anyway. Please consider storing sensitive information on the server and only expose what's absolutely necessary to the client instead.
Starting from version 1.1.0, this option will be completely ignored.
Overview
Type: enum
This only concerns React for the time being.
This is used to control whether state values will be exposed in the React Developer Tools but only applies to StateManager and AsyncStateManager.
This can be specified in the options parameter in the constructor of the State Manager:
import { StateManager, StateManagerVisibility } from 'cotton-box'
const ExampleState = new StateManager('Hello, world!', {
visibility: StateManagerVisibility.HIDDEN,
})
Values
| Key | Value | Description |
|---|---|---|
ENVIRONMENT | 0 | State values will be exposed in non-production environments, but hidden in production environment. |
EXPOSED | 1 | State values will be always exposed regardless of the environment. |
HIDDEN | 2 | State values will be always hidden regardless of the environment. |
The screenshots below show how State Managers with different visibility values appear in the React Developer Tools.
StateManagerVisibility.HIDDEN:

StateManagerVisibility.EXPOSED:
