【发布时间】:2019-04-20 23:57:21
【问题描述】:
您好,我创建了一个新应用。
- react-native init AwesomeProject
- cd AwesomeProject
- npm install --save react-navigation
- npm install --save react-native-gesture-handler
- react-native 链接
- react-native run-ios
每次都出错。如果有人有任何理想如何克服这个问题,那就太好了
TypeError: instance.render is not a function. (In 'instance.render()', 'instance.render' is undefined)
This error is located at:
in ScreenContainer (at StackViewLayout.js:300)
in RCTView (at View.js:45)
in AnimatedComponent (at StackViewLayout.js:298)
in Handler (at StackViewLayout.js:279)
in StackViewLayout (at withOrientation.js:30)
in withOrientation (at StackView.js:96)
in RCTView (at View.js:45)
in Transitioner (at StackView.js:22)
in StackView (at createNavigator.js:62)
in Navigator (at createKeyboardAwareNavigator.js:12)
in KeyboardAwareNavigator (at createAppContainer.js:388)
in NavigationContainer (at renderApplication.js:34)
in RCTView (at View.js:45)
in RCTView (at View.js:45)
in AppContainer (at renderApplication.js:33)
finishClassComponent
index.bundle?platform=ios&dev=true&minify=false:16219:43
performUnitOfWork
index.bundle?platform=ios&dev=true&minify=false:19455:27
workLoop
index.bundle?platform=ios&dev=true&minify=false:19489:47
renderRoot
index.bundle?platform=ios&dev=true&minify=false:19560:21
performWorkOnRoot
index.bundle?platform=ios&dev=true&minify=false:20280:23
performWork
index.bundle?platform=ios&dev=true&minify=false:20207:30
performSyncWork
index.bundle?platform=ios&dev=true&minify=false:20183:20
requestWork
index.bundle?platform=ios&dev=true&minify=false:20062:26
scheduleWork
index.bundle?platform=ios&dev=true&minify=false:19934:22
scheduleRootUpdate
index.bundle?platform=ios&dev=true&minify=false:20451:21
render
index.bundle?platform=ios&dev=true&minify=false:20921:26
renderApplication
index.bundle?platform=ios&dev=true&minify=false:68557:59
run
index.bundle?platform=ios&dev=true&minify=false:68238:28
runApplication
index.bundle?platform=ios&dev=true&minify=false:68288:28
__callFunction
index.bundle?platform=ios&dev=true&minify=false:2470:49
<unknown>
index.bundle?platform=ios&dev=true&minify=false:2243:31
__guard
index.bundle?platform=ios&dev=true&minify=false:2424:15
callFunctionReturnFlushedQueue
index.bundle?platform=ios&dev=true&minify=false:2242:21
package.json
{
"name": "AwesomeProject",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"react": "16.6.1",
"react-native": "0.57.5",
"react-native-gesture-handler": "^1.0.9",
"react-navigation": "^3.0.0"
},
"devDependencies": {
"babel-jest": "23.6.0",
"jest": "23.6.0",
"metro-react-native-babel-preset": "0.49.2",
"react-test-renderer": "16.6.1"
},
"jest": {
"preset": "react-native"
}
}
app.js
// In App.js in a new project
import React from "react";
import { View, Text } from "react-native";
import { createStackNavigator, createAppContainer } from "react-navigation";
class HomeScreen extends React.Component {
render() {
return (
<View style={{ flex: 1, alignItems: "center", justifyContent: "center" }}>
<Text>Home Screen</Text>
</View>
);
}
}
const AppNavigator = createStackNavigator({
Home: {
screen: HomeScreen
}
});
export default createAppContainer(AppNavigator);
【问题讨论】:
-
遇到同样的错误你找到解决方法了吗?
-
不,我无法找到解决方案已转到 react-navigation 2
标签: react-native react-navigation