zalmoxisus / mobx-remotedev

MobX DevTools extension
MIT License
328 stars 40 forks source link

Doesn't capture anything if useStrict is enabled #29

Open JReinhold opened 7 years ago

JReinhold commented 7 years ago

I have a weird problem. remotedev won't show any activity in the Chrome extension window if I enable MobX's useStrict. It will correctly show the stores, but only with default values, and will never react to actions or changed observables. The app is working fine, and mobx-react-devtools works fine as well. As soon as I remove useStrict(true) it works perfectly.

My setup:

Example store

// circle-chart.moby.ts

import remotedev from 'mobx-remotedev/lib/dev';
import { action, observable, runInAction } from 'mobx';

@remotedev
export class CircleChartStore {
    @observable circleChartValue = 0;

    @action
    async fetchValue() {
        const percentage = /* does async stuff here*/

        runInAction('Update fetched Circle Chart data', () => {
            this.circleChartValue = percentage;
        });
    }
}

Example React app

// index.tsx

import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { Grid } from './grid/';
import { Provider } from 'mobx-react';
import DevTools from 'mobx-react-devtools';
import { CircleChartStore } from './circle-chart.moby';
import { useStrict } from 'mobx';

useStrict(true);

function initStores(): AllStores {
    const circleChartStore = new CircleChartStore();
    /** more stores here **/

    return { circleChartStore, /** more stores **/ };
}

const mobxStores = initStores();

ReactDOM.render(
    <Provider {...mobxStores} >
        <div>
            <DevTools />
            /** App here **/
        </div>
    </Provider>
,
    document.getElementById('root') as HTMLElement,
);

I am running Redux as well, but haven't enabled the DevTools extension for my Redux store.

Another, maybe related problem

I HAVE to import remotedev using import remotedev from 'mobx-remotedev/lib/dev';, it won't work using the normal import, even though I KNOW that process.env.NODE_ENV === 'development' because I use that elsewhere in the app without failure. I don't know if this is related or not, but I thought that it might be nice to know.

thedanheller commented 5 years ago

@JReinhold were you able to fix this issue? I'm facing kind of the same thing, except that I can't make it work at all 😕 opened #47.

JReinhold commented 5 years ago

@daniloprates, unfortunately not, I haven't used this library in years, so I'm afraid I won't be able to help you out.

thedanheller commented 5 years ago

No probls @JReinhold :) thanks