Mobx: Error: MobX injector: Store 'StoreName' is not available! Make sure it is provided by some Provider

Created on 15 Nov 2017  路  3Comments  路  Source: mobxjs/mobx

I am relatively new to MobX and trying to migrate from Redux to MobX in my React-Native development.

My code work on my debug app, but got error on release build. Here is the logcat:

Error: MobX injector: Store 'PlayerStore' is not available! Make sure it is provided by some Provider
This error is located at:
     in inject-t-with-PlayerStore
     in n
     in RCTView
     in RCTView
     in t

My Store

import { observable, action } from 'mobx'

class PlayerStore {
    @observable isPlaying = false
    ...
}
export default PlayerStore

...
// Store index
const stores = {
    PlayerStore: new PlayerStore()
}

export default {
    ...stores
}

Since i am using react-native-navigation from wix i can't use built in Provider component, so i use the provider from this gist

And here is how i use the inject on my Screen Component:

...
import {observer, inject} from 'mobx-react/native'

@inject("PlayerStore")
@observer 
export default class HomeScreen extends Component {
    ...
}

The error only happen on release build and causing the app not running at all.

Thanks.

All 3 comments

What does this do? Navigation.registerComponent('myapp.HomeScreen', () => HomeScreen, store, Provider);

@mweststrate already did that

export function registerScreens(store: {} , Provider: {}) {
    Navigation.registerComponent('app.HomeScreen', () => HomeScreen, store, Provider);
}

starting from scratch based on https://github.com/kanzitelli/react-native-navigation-mobx-boilerplate working perfectly. It's weird what caused the issue though

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mehdi-cit picture mehdi-cit  路  3Comments

rodryquintero picture rodryquintero  路  3Comments

bb picture bb  路  3Comments

weitalu picture weitalu  路  3Comments

geohuz picture geohuz  路  3Comments