Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't capture anything if useStrict is enabled #29

Open
JReinhold opened this issue Sep 12, 2017 · 3 comments
Open

Doesn't capture anything if useStrict is enabled #29

JReinhold opened this issue Sep 12, 2017 · 3 comments

Comments

@JReinhold
Copy link

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:

  • mobx-remotedev @0.2.8
  • create-react-app with react-scripts-ts @ 2.6.0 (using TypeScript)
  • mobx @3.2.2
  • mobx-react @4.2.2
  • mobx-react-devtools @4.2.15

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
Copy link

@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
Copy link
Author

@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
Copy link

No probls @JReinhold :) thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants