How to use the mobx.useStrict function in mobx

To help you get started, we’ve selected a few mobx examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Soltsice / Soltsice / src / index.tsx View on Github external
import { useStrict } from 'mobx';
import { Provider } from 'mobx-react';
import { Router, Route, Switch } from 'react-router';
import { Link } from 'react-router-dom';

import { Root } from './containers/Root';
// import App from './App';
import registerServiceWorker from './registerServiceWorker';
import * as state from './stores';

import { App } from './components/App';

import { NotFound } from './components/NotFound';

// enable MobX strict mode
useStrict(true);

// render react DOM
ReactDOM.render(
  
    
      
        <div>
          <ul>
            <li>Home</li>
            <li>App</li>
            <li>Not found</li>
          </ul>
          </div>
github Emurgo / yoroi-frontend / chrome / extension / index.js View on Github external
import React from 'react';
import { render } from 'react-dom';
import { action, useStrict } from 'mobx';
import { RouterStore, syncHistoryWithStore } from 'mobx-react-router';
import { hashHistory } from 'react-router';
import { setupApi } from '../../app/api/index';
import createStores from '../../app/stores/index';
import translations from '../../app/i18n/translations';
import actions from '../../app/actions/index';
import Action from '../../app/actions/lib/Action';
import App from '../../app/App';
import '../../app/themes/index.global.scss';

// run MobX in strict mode
useStrict(true);

// Entry point into our application
const initializeYoroi = async () => {
  const api = setupApi();
  const router = new RouterStore();
  const history = syncHistoryWithStore(hashHistory, router);
  const stores = createStores(api, actions, router);

  window.yoroi = {
    api,
    actions,
    translations,
    stores,
    reset: action(() => {
      Action.resetAllActions();
      createStores(api, actions, router);
github mobx-little-router / mobx-little-router / packages / mobx-little-router-react / config / jest.js View on Github external
// Jest setup
import { useStrict } from 'mobx'
import { JSDOM } from 'jsdom'

useStrict(true)

const jsdom = new JSDOM('')
const { window } = jsdom

function copyProps(src, target) {
  const props = Object.getOwnPropertyNames(src)
    .filter(prop =&gt; typeof target[prop] === 'undefined')
    .map(prop =&gt; Object.getOwnPropertyDescriptor(src, prop))
  Object.defineProperties(target, props)
}

global.window = window
global.document = window.document
global.navigator = {
  userAgent: 'node.js'
}
github lightninglabs / lightning-app / test / unit / computed / loader-msg.spec.js View on Github external
beforeEach(() => {
    useStrict(false);
    store = observable({
      percentSynced: 0,
    });
  });
github zhw2590582 / snippets-box / src / index.js View on Github external
import React from 'react';
import { render } from 'react-dom';
import { useStrict } from 'mobx';
import { Provider } from 'mobx-react';
import { AppContainer } from 'react-hot-loader';
import 'promise-polyfill';
import 'whatwg-fetch';
import stores from './stores';
import App from './components/App';
import { ThemeProvider } from 'styled-components';
import theme from './styles/theme';
import './styles/global';
import { LocaleProvider } from 'antd';
import enUS from 'antd/lib/locale-provider/en_US';

useStrict(true);

const renderApp = Component =&gt; {
  render(
    
      
        
          
            
          
        
      
    ,
    document.getElementById('root')
  );
};
github wasd171 / chatinder / src / app / index.tsx View on Github external
async function configureAndRender() {
	const container = document.getElementById('root')

	const theme = configureTheme()
	const client = configureClient()
	const stores = await configureStores(client)
	useStrict(true)

	function render() {
		const App = require('./scenes/App/index').default
		ReactDOM.render(
			
				
					
						
							
						
					
				
			,
			container,
			() =&gt; {}
		)
github microsoft / Orb / dist / resources / app / state / state.ts View on Github external
private static createInitialState(): OrbState {
        useStrict(true);
        ipcRenderer.on("state-manager-persistStateOnClose", () => {
            StateManager.saveStateToLocalStorage();
            ResourceSuggestionDB.instance().destroy();
            ipcRenderer.send("state-manager-persistStateOnCloseCompleted");
        });

        ipcRenderer.on("state-manager-persistStateOnReload", () => {
            StateManager.saveStateToLocalStorage();
            ipcRenderer.send("state-manager-persistStateOnReloadCompleted");
        });

        ipcRenderer.on("state-manager-set-state", (event, fileData) => {
            let parsedData = JSON.parse(fileData);
            StateManager.clearStoreForSetState();
            StateManager.applyFileFormatStateToStore(parsedData);
        });
github phiresky / backchannel-prediction / web_vis / ts / client.tsx View on Github external
import * as React from "react";
import * as ReactDOM from "react-dom";
import * as mobx from "mobx";
mobx.useStrict(true);
import { observer } from "mobx-react";
import * as util from "./util";
import DevTools from "mobx-react-devtools";
import * as s from "./socket";
import * as LZString from "lz-string";
import { autobind } from "core-decorators";
import * as B from "@blueprintjs/core";
import * as Data from "./Data";
import * as v from "./Visualizer";
import { Feature, NumFeature, NumFeatureSVector, FeatureID, ConversationID } from "./features";
import { AudioPlayer, PlaybackPosition, AudioRecorder, microphoneFeature, RegionSelector } from "./Audio";
import * as queryString from "query-string";
import * as x from "./RpcWebWorker";
x;
export const globalConfig = mobx.observable({
    maxColor: "#3232C8",
github getfireside / fireside / client / src / app / index.js View on Github external
import ReactDOM from 'react-dom';
import React from 'react';

import initFS from 'lib/fs/initfs';
import {clock} from 'lib/util';
import {LoggingController} from 'lib/logger';

import {RecordingStore, MessageStore} from 'app/stores';
import Room from 'app/rooms/room';
import RoomController from 'app/rooms/controller';
import UIApp from 'app/ui/components/app';
import UIStore from 'app/ui/store';
import {useStrict} from 'mobx';
import {startSyncingTime} from 'lib/timesync';

useStrict(true);

export default class FiresideApp {
    constructor({roomData, opts}) {
        this.opts = opts;

        startSyncingTime();

        this.clock = clock;
        clock.start();

        this.setupLogger();
        this.setupFS();
        this.setupStores({selfId: roomData.self.id});
        this.setupRoom(roomData, opts);
    }
github roberth26 / wp-react / src / stores / GlobalStore.ts View on Github external
import { observable, computed, useStrict, action, runInAction } from 'mobx';
import { Location } from 'history';
import { matchPath } from 'react-router-dom';
import Page from '../models/Page';
import Form from '../models/Form';
import Menu from '../models/Menu';
import Theme from '../models/Theme';
import Color from '../dataTypes/Color';
import EThemeLocation from '../contracts/EThemeLocation';
import WidgetArea from '../models/WidgetArea';

useStrict( true );

export default class GlobalStore {
    @observable location: Location = null;
    @observable theme: Theme = null;
    @observable private widgetAreaMap: Map = new Map();
    @observable private pageMap: Map = new Map();
    @observable private formMap: Map = new Map();
    @observable private menuMap: Map = new Map();
    private previousPage: Page;

    @action addWidgetArea( ...widgetAreas: WidgetArea[] ): GlobalStore {
        runInAction(() =&gt; {
            [ ...widgetAreas ]
                .forEach( widgetArea =&gt; {
                    this.widgetAreaMap.set( widgetArea.themeLocation.toString(), widgetArea );
                });