给定以下设置:
import { AppRegistry } from "react-native";
import { Provider } from "mobx-react";
import Application from "./src/components/Application";
import ApplicationStore from "./src/stores/ApplicationStore";
import { name as appName } from "./app.json";
let app = ApplicationStore.create();
AppRegistry.registerComponent(name, () => (
<Provider app={app}>
<Application />
</Provider>
));
ApplicationStore未定义,因此无法创建...Cannot read property 'create' of undefined
Module AppRegistry is not a registered callable module (calling runApplication)
有没有更好的方法来设置ApplicationStore,并通过注入使其可用于组件?
const Application = inject("app")(
observer(
class Application extends Component {
...
这就是我在react apps()中所做的,尽管是通过ReactDOM.render()
。
1条答案
按热度按时间rxztt3cl1#
好吧,尽职调查是为了赢!
然后在组件内部:
现在,商店可用于所有组件,并在应用程序启动时示例化...