Skip to main content

StateManagerVisibility

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

KeyValueDescription
ENVIRONMENT0State values will be exposed in non-production environments, but hidden in production environment.
EXPOSED1State values will be always exposed regardless of the environment.
HIDDEN2State 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.

With StateManagerVisibility.HIDDEN:Inspecting an exposed state in React Dev ToolsInspecting an exposed state in React Dev Tools
With StateManagerVisibility.EXPOSED:Inspecting a hidden state in React Dev ToolsInspecting a hidden state in React Dev Tools