我正在尝试使用react-native-navigation和来自reduxpersistStore的persistStore启动我的应用程序。 我收到警告,功能作为React child无效。如果您返回Component而不是从render返回,则可能会发生这种情况。
是否有任何解决方法可启动此初始屏幕,最近我添加了startApp函数并在render内部调用它。
这是我启动应用程序的初始组件:
import React, { Component } from "react";
import { Provider } from "react-redux";
import { View, Text } from "react-native";
import { persistStore } from "redux-persist";
import { Navigation } from "react-native-navigation";
import Mapbox from "@mapbox/react-native-mapbox-gl";
import { registerScreens } from "./screens";
import store from "./store/configureStore";
import { appInit, getInitialScreen } from "./appInit";
import { handleErrorObject } from "./lib/handleError";
Mapbox.setAccessToken("pk.eyJ123425KKbcgNww");
export default class App extends Component {
startApp = () => {
const persistor = persistStore(store, null, () => {
registerScreens(store, Provider);
appInit(store)
.then(() => {
const initialScreen = getInitialScreen(store.getState());
Navigation.startSingleScreenApp({
screen: {
screen: initialScreen
},
passProps: {
persistor
},
drawer: {
left: {
screen: "DrawerMenuScreen"
}
},
appStyle: {
orientation: "portrait"
}
});
})
.catch(error => {
handleErrorObject("Error initializing app", error);
});
});
};
render() {
return <View>{this.startApp}</View>;
}
}