Debug your Unstated containers with ease
Switch branches/tags
Clone or download
Latest commit 64ef46f Oct 15, 2018
Permalink
Failed to load latest commit information.
.editorconfig Init Apr 3, 2018
.gitattributes Init Apr 3, 2018
.gitignore Init Apr 3, 2018
.npmrc Init Apr 3, 2018
.travis.yml Init Apr 3, 2018
browser-env.js Simplify setting up debugging (#1) Apr 16, 2018
index.js Fix SSR (#8) Oct 15, 2018
license Init Apr 3, 2018
package.json 0.3.2 Oct 15, 2018
readme.md Fix usage example in the readme (#7) Oct 12, 2018
screenshot-diff.png Init Apr 3, 2018
screenshot-explore.png Init Apr 3, 2018
screenshot.png Init Apr 3, 2018
test.js Simplify setting up debugging (#1) Apr 16, 2018

readme.md

unstated-debug Build Status

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';

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 by default.
  • 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.

License

MIT © Sindre Sorhus