Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on May 2, 2024. It is now read-only.

sindresorhus/unstated-debug

Repository files navigation

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.

About

Debug your Unstated containers with ease

Topics

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published

Contributors 8

AltStyle によって変換されたページ (->オリジナル) /