unstated-debug
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

unstated-debug

Debug your Unstated containers with ease


Install

$ npm install unstated-debug

Setup

In the root of your app, import unstated-debug:

import React from 'react';
import {render} from 'react-dom';
import {Provider} from 'unstated';
import UNSTATED from 'unstated-debug';
import App from './components/App.js';

UNSTATED.logStateChanges = false;

render(
	<Provider>
		<App/>
	</Provider>,
	document.querySelector('#root')
);

Usage

When enabled, it exposes a global object UNSTATED which you can use in DevTools to explore the containers and their state.

The object contains the following properties:

  • isEnabled - Same as the below option, but you can change it after init.
  • logStateChanges - Same as the below option, but you can change it after init.
  • isCollapsed - Collapse logs. (Default: false)
  • containers - Your containers.
  • states - The state objects of your containers.
  • logState() - Logs the current state of your containers.

API

UNSTATED

isEnabled

Type: boolean
Default: true

Toggle debugging.

For example, if you use this in an Electron app, you could pass it is.development to ensure debugging is disabled in production.

logStateChanges

Type: boolean
Default: true

Logs a diff for each state change to the containers. This gives you a live insight into state changes in your app.

Package Sidebar

Install

npm i unstated-debug

Weekly Downloads

1,143

Version

1.0.0

License

MIT

Unpacked Size

6.5 kB

Total Files

5

Last publish

Collaborators

  • sindresorhus