react-native: TypeError: undefined is not a function (evaluating 'instance.render()')
Environment
- OS: Windows 10
- Node: 8.11.4
- Yarn: 1.9.4
- npm: 6.4.1
- react-native-cli: 2.0.1
- react-native: 0.57.5
Description
TypeError: undefined is not a function (evaluating ‘instance.render()’) This error is located at: in AppContainer (at renderApplication.js:33)
Reproducible Demo
— package.json —
{
"name": "test",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"@babel/core": "^7.1.6",
"babel-core": "^6.26.3",
"react": "16.6.1",
"react-native": "0.57.5"
},
"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"
}
}
very simple. just “react-native run-android” and tada !!
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 4
- Comments: 25 (4 by maintainers)
finally i’ve found the solution. at least it works for me. i’ve moved to here. it even teaches you how to migrate from here 😆
Hi, Have you found any solution to this problem? I am facing the same problem
@cassianomon’s suggestion to use the class field double arrow solved it for me as well:
render = () => {
instead ofrender() {
Geez, I just wasted about an hour until I figured out that the solution (at least for my problem), was:
Use this version to resolve this error 😃. I have tested it, and worked fine: “react”: “16.6.3”, “react-native”: “0.58.0-rc.2”
Hello there 👋 this issue has been reported for an old version of React Native. Ideally we’d like everyone to be using 0.59 (see the awesome changes it brought) but we know updating can be a pain. We are going to close this issue because it’s from a version before 0.57, which is really old.
But please, if it’s actually still an issue with 0.59 please comment below and we can reopen it 😊
I solved it .with:
My own error was coming up because i had no
render()
method in the class component.Maybe you add a render method and see if it works.
Seeing this with 0.59. I’ve tried 14 different babel presets, from just
preset-env
tobabel-preset-react-native
and the defaultmodule:metro-react-native-babel-preset
. In all cases, replacing render with an arrow function fixes the issue, but fails otherwise.I have the same issue, using RN 0.57.7