我无法从代码中解决此问题。.当我切换到filmdetail视图时,出现此错误:错误:MobX进样器:存储'...'不可用!确保它是由某些提供商提供的
这是我的app.js APP.JS
import React from 'react';
import {StyleSheet, View, Text} from "react-native";
import Navigation from './Navigation/Navigation';
import FilmStore from './Stores/FilmStore';
export default class App extends React.Component {
constructor(props){
super(props);
}
render() {
return (
<View>
<Text>{FilmStore.test}</Text>
<Navigation filmStore={FilmStore} />
</View>
);
}
}
这里是来自React Navigation的导航 Navigation.JS
import { createStackNavigator } from 'react-navigation';
// Views
import Search from '../Components/Search'
import FilmDetail from "../Components/FilmDetail";
const SearchStackNavigator = createStackNavigator({
Search: {
screen: Search,
navigationOptions: {
title: 'Rechercher'
}
},
FilmDetail: {
screen: FilmDetail,
navigationOptions: {
title: 'Détail'
}
},
});
export default SearchStackNavigator;
这里是胶片细节视图 FilmDetail.JS
import React from 'react'
import Moment from 'moment';
import { observer, inject } from 'mobx-react';
import {StyleSheet, View, Text, ActivityIndicator, ScrollView, Image, Button} from 'react-native'
import {getDetail, getImageURI} from "../API/TMDBApi";
@inject('filmStore')
@observer
class FilmDetail extends React.Component {
constructor(props){
super(props);
console.log(props);
}
render() {
return (
<View>
</View>
)
}
}
export default FilmDetail
寻求帮助:) 谢谢 !
答案 0 :(得分:0)
我替换为app.js
..
import { observer } from 'mobx-react';
..
render() {
return (
<View>
<Text>{FilmStore.test}</Text>
<Navigation filmStore={FilmStore} />
</View>
);
}
作者
..
import { observer, Provider } from 'mobx-react';
..
render() {
return (
<Provider filmStore={filmStore}>
<View style={styles.mainContainer}>
<Text>{filmStore.test}</Text>
<Navigation />
</View>
</Provider>
);
}
现在,它可以完美运行。