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.
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