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

Update Mobx devDependencies to peerDependencies #2960

Closed
thereis opened this issue Mar 23, 2018 · 1 comment
Closed

Update Mobx devDependencies to peerDependencies #2960

thereis opened this issue Mar 23, 2018 · 1 comment

Comments

@thereis
Copy link

thereis commented Mar 23, 2018

Version

Tell us which versions you are using:

  • react-native-router-flux@4.0.0-beta.28
  • mobx@4.1.0
  • mobx-react@5.0.0

Expected behaviour

I was trying to configure and use mobx as my default state management, but I had some problems while configuring it, because the new version of mobx@4.1.0 and mobx-react@5.0.0, only accepts 1 instance.

react-native-router-flux uses and old version for both of them and is configured as devDependencies
inside of package.json.

Actual behaviour

It's crashing the application after importing an observable, printing the following output:

[mobx] There are multiple mobx instances active. This might lead to unexpected results: See https://github.com/mobxjs/mobx/issues/1082 for details.

Steps to reproduce

  1. Create a simple react-native project.
  2. Install react-native-router-flux: npm install react-native-router-flux
  3. Install mobx and mobx-react with the latest version: npm install mobx mobx-react
  4. Create a simple observable object and import it in App.js or even in index.js
  5. It's expected to output the following error [mobx] There are multiple mobx instances active. This might lead to unexpected results: See https://github.com/mobxjs/mobx/issues/1082 for details..

Steps to fix

There is a topic created by the developer of Mobx, explaining how to fix this issue for "library developers", mobx issue #1082.

My workaround to fix this problem, was adding the property resolutions to my package.json and use yarn as package manager. This is my package.json

{
  "name": "reactnativetestapp",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "mobx": "^4.1.0",
    "mobx-react": "^5.0.0",
    "react": "16.3.0-alpha.1",
    "react-native": "0.54.2",
    "react-native-elements": "^0.19.0",
    "react-native-router-flux": "^4.0.0-beta.28",
    "react-native-vector-icons": "^4.5.0"
  },
  "devDependencies": {
    "mobx": "^4.1.0",
    "mobx-react": "^5.0.0",
    "babel-jest": "23.0.0-alpha.0",
    "babel-plugin-module-resolver": "^3.1.0",
    "babel-plugin-transform-decorators-legacy": "^1.3.4",
    "babel-preset-react-native": "4.0.0",
    "jest": "22.4.2",
    "react-test-renderer": "16.3.0-alpha.1"
  },
  "resolutions": {
    "mobx": "^4.1.0",
    "mobx-react": "^5.0.0"
  },
  "jest": {
    "preset": "react-native"
  }
}

Then, I just run yarn install and react-native run-android.

@thereis thereis changed the title Update Mobx to peerDependencies Update Mobx devDependencies to peerDependencies Mar 23, 2018
@aksonov
Copy link
Owner

aksonov commented Aug 8, 2018

Closing it now because beta.40 doesn't use mobx

@aksonov aksonov closed this as completed Aug 8, 2018
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