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

0.0.19 • Public • Published

mobx-preact-devtools (in developing)

DevTools for MobX to track the rendering behavior and data dependencies of your app.

It is a fork from original react mobx devtools ( to work with preact instead of react.

MobX DevTools


npm install --save-dev mobx-preact-devtools


Somewhere in your application, create a DevTools component:

import { h, Component } from 'preact';
import DevTools from 'mobx-preact-devtools';

class MyApp extends Component {
  render() {
    return (
        <DevTools />

Supported props:

  • highlightTimeout — number, default: 1500
  • noPanel — boolean, if set, do not render control panel
  • position — object, position of control panel, default: { top: -2, right: 20 }
  • className — string, className of control panel
  • style — object, inline style object of control panel
  • position — string or object, topRight, bottomRight, bottomLeft or topLeft, default: bottomRight

The position of the panel can be tweaked by setting the value to an object with top, right, bottom or left defined. Setting it to { top: -2, right: 20 } is the same as topRight.

From there on, after each rendering a reactive components logs the following three metrics:

  1. Number of times the component did render so far
  2. The time spend in the render() method of a component
  3. The time spend from the start of the render() method until the changes are flushed to the DOM

For each component the color indicates roughly how long the coloring took. Rendering times are cumulative; they include time spend in the children

  • Green: less then 25 ms
  • Orange: less then 100 ms
  • Red: rendering for this component took more than 100ms

About log groups

Note that if logging is enabled, MobX actions and reactions will appear as collapsible groups inside the browsers console. Mind that any log statements that are printed during these (re)actions will appear inside those groups as well, so that you can exactly trace when they are triggered.


import { configureDevtool } from 'mobx-preact-devtools';

// Any configurations are optional
  // Turn on logging changes button programmatically:
  logEnabled: true,
  // Turn off displaying components updates button programmatically:
  updatesEnabled: false,
  // Log only changes of type `reaction`
  // (only affects top-level messages in console, not inside groups)
  logFilter: change => change.type === 'reaction',

There are also aliases for turning on/off devtools buttons:

import { setLogEnabled, setUpdatesEnabled, setGraphEnabled } from 'mobx-preact-devtools';

setLogEnabled(true); // same as configureDevtool({ logEnabled: true });
setUpdatesEnabled(false); // same as configureDevtool({ updatesEnabled: false });
setGraphEnabled(false); // same as configureDevtool({ graphEnabled: false });

Custom panel design

import { h, Component } from 'preact';
import DevTools, { GraphControl, LogControl, UpdatesControl } from 'mobx-preact-devtools';

class MyNiceButton extends Component {
  render() {
    const { active, onToggle, children } = this.props;
    return (
      <button onClick={onToggle}>
        {active ? ' on' : ' off'}

class MyApp extends Component {
  render() {
    return (

        {/* Include somewhere with `noPanel` prop. Is needed to display updates and modals */}
        <DevTools noPanel />

        <div className="my-custom-devtools-panel-design">
            {/* Must have only one child that takes props: `active` (bool), `onToggle` (func) */}
            {/* Must have only one child that takes props: `active` (bool), `onToggle` (func) */}
            {/* Must have only one child that takes props: `active` (bool), `onToggle` (func) */}


0.0.1 Changed Readme, package.json and remote git repo

0.0.2 Migrated to preact from react, added babel plugin and preset for preact

0.0.3 updated Readme

0.0.5 removed prop-types, because they are compatible with preact

0.0.6 removed all mobx-react dev dependencies

0.0.7 removed React in UpdatedControl.jsx

0.0.8 removed cloneElement method from react library

0.0.9 moved PanelButton to main components: LogControl, GraphControl and UpdatesControl

Package Sidebar


npm i mobx-preact-devtools

Weekly Downloads






Unpacked Size

297 kB

Total Files


Last publish


  • vlad_opaets