React Native问题集合

1.Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.


少了export default class

2.The development server returned response error code: 500

语法错误

3.

ReferenceError: Can't find variable: View

没有引用模块

4.TypeError: undefined is not a function (evaluating 'this.renderItem()')

5.注释无作用?

Unexpected token ';' (http://10.0.2.2:8081/index.delta?platform=android&dev=true&minify=false:85772)

Unexpected token ';' (http://10.0.2.2:8081/index.delta?platform=android&dev=true&minify=false:85772)

6.reload,hot reload 有时无效。需要重新run

7.Application viewdemo has not been registered.

Hint: This error often happens when you're running the packager (local dev server) from a wrong folder. For example you have multiple apps and the packager is still running for the app you were working on before.

If this is the case, simply kill the old packager instance (e.g. close the packager terminal window) and start the packager in the correct app folder (e.g. cd into app folder and run 'npm start').

8.Invariant Violation: Text strings must be rendered within a <Text> component.

注释未被编译器识别?

注意可能有空格在组件外的情况,

9.undefined is not an object (evaluating 'scrollerView.scrollTo')

The development server returned response error code: 500

10.undefined is not an object (evaluating 'RootComponent.prototype')

renderApplication

import { Navigate } from './Navigate';  括号问题。

11.图片填不满scrollview布局

1.图片大小问题,

2.resizemode属性

3.在滚动的时候把width适当增加一些(+8)

4. (虚拟机上测试无效)    layout_height="match_parent"

                            fillViewport="true"

12.引号怎么表示?

13.<Image source={{uri: 'mipmap/img_1'}}

这种方式加载图片时,用flex:1无效

必须指定宽高才有效。。

14.android studio:无法格式化js

        1.import CSS & JavaScript file types:https://github.com/manifestinteractive/android-studio-filetypes.

        2.installed JS toolbox plugin.

15.does not exist in the Haste module map  

解决方案:在项目中的模块是软连接建立的,删除软连接,把模块目录复制过来后运行正常。

以下是网络上其它解决方案,未全部尝试,以上不能解决可尝试。

注意:不要使用 cnpm!cnpm 安装的模块路径比较奇怪,packager 不能正常识别!

1.Ran into this too withbabel-plugin-dotenv-import(which is very similar to react-native-dotenv). The solution is toimport all dotenv defines in a single fileand then ignore that file for coverage:

    "coveragePathIgnorePatterns": 

        ["/node_modules/"

        ,"/src/utils/env.js"],

2.https://blog.csdn.net/u010127332/article/details/83622209

3.Move into your Project folder :

        1.rm -rf node_modules

        2.npm install

        3.Insidepackage.json. Check if all the modules are present.

        4.react-native start --reset-cache

4.I had the same issue and resolved it by adding react-native-dotenv plugin to .babelrc

"presets": [ "react-native", "module:react-native-dotenv" ]

 and importing vars via:

import {VAR1,VAR2} from 'react-native-dotenv';


5.I had similar problem - what helped was running npm start -- --reset-cache command.

6.npm add @babel/runtime work for me.


7.Seeing this issue when upgrading to RN 0.57. I've tried all suggestions and nothing worked for me. In the end I switched to react-native-config, it's slightly more annoying to setup but it works with the same .env files


16.Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.


类文件修改:export  default


17. TypeError: undefined is not an object (evaluating '_reactNative.NativeModules.UIManager.RCTVideo.Constants')


18.Invariant Violation: requireNativeComponent: "BVLinearGradient" was not found in the UIManager.

安装模块后,要link: react-native link react-native-button-component



18.Cannot find module 'asap/raw'


19.npm添加其它包时,各种找不到文件。报错。

npm ERR! path D:\React_Native_Project\NativeBase-KitchenSink-master\node_modules\.staging\react-native-vector-icons-1b37ab4d\node_modules\is-fullwidth-code-point

npm ERR! code ENOENT

npm ERR! errno -4058

npm ERR! syscall rename

npm ERR! enoent ENOENT: no such file or directory, rename 'D:\React_Native_Project\NativeBase-KitchenSink-master\node_modules\.staging\react-native-vector-icons-1b37ab4d\node_modules\is-fullwidth-code-point' -> 'D:\React_Native_Project\NativeBase-KitchenSink-master\node_modules\.staging\is-fullwidth-code-point-62fb003f'

npm ERR! enoent This is related to npm not being able to find a file.

npm ERR! enoent


换yarn或者其他 包管理器试试。


20.> Task :app:installDebug FAILED

Skipping device '2230e2fc - 7.0' for 'app:debug': Could not find build of variant which supports density -1 and an ABI in

开关开发者模式,开关usb调试.,撤销usb授权,重启机器. 

21.

Skipping device '2230e2fc' for 'app:debug': Unknown API Level

项目的sdk版本与手机android版本不匹配.

开关开发者模式,开关usb调试.,撤销usb授权,重启机器. 

22.FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

经过搜索,最后的解决方案是删除npmrc文件(不是nodejs安装目录npm模块下的那个npmrc文件,而是C:\Users\{账户}\下的.npmrc文件)。

23.Failed to find target with hash string '28' in: D:\AndroidSDK

gradle版本引起,在build.gradle(两个)中检查几个参数版本解决.

24.

Unable to install D:\glen\RNAnimationDemo\android\app\build\outputs\apk\debug\app-debug.apk

com.android.ddmlib.InstallException


25.Error: EPERM: operation not permitted, lstat 'D:\glen\RNAnimationDemo\android\app\build\intermediates\assets\debug\fonts'


26.Could not merge source set folders:

27.undefined is not an object

( evaluating props.sections.reduce.)

28.

```

Could not resolve all files for configuration ':app:debugCompileClasspath'.

> Could not resolve com.facebook.react:react-native:+.

  Required by:

      project :app

  > Could not resolve com.facebook.react:react-native:+.

      > Failed to list versions for com.facebook.react:react-native.

        > Unable to load Maven meta-data from https://jcenter.bintray.com/com/facebook/react/react-native/maven-metadata.xml.

            > Could not HEAD 'https://jcenter.bintray.com/com/facebook/react/react-native/maven-metadata.xml'. Received status code 502 from server: Bad Gateway

```

29. Error while updating property 'width' in shadow node of type :RCTTEXT


30.can not perform a react state update on an unmounted component this is a no-op, but it indicated a memory leak in your application.


31.error An unexpected error occurred: "unsure how to copy this: /Users/betadmin/Library/Application Support/Code/1.34.0-main.sock".

删除lock文件,再yarn


32.react native String does not match the pattern of "^(?:@[a-z0-9-~][a-z0-9-._

包名只能小写..

33.模拟器上运行没问题,真机直接崩溃,

重新初始化项目,拷贝代码重建. react native 版本和react 版本最好都保持一致


34.Cannot fit requested classes in a single dex file

1,在android/app/build.gradle中添加

```

android {

    defaultConfig {

         multiDexEnabled true

    }

}

dependencies {

   implementation 'com.android.support:multidex:1.0.3'

}

```

##并不需要修改MainApplication.java

#####精彩稍后继续,尽请点赞打赏.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 217,542评论 6 504
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 92,822评论 3 394
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 163,912评论 0 354
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,449评论 1 293
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,500评论 6 392
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,370评论 1 302
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,193评论 3 418
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 39,074评论 0 276
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,505评论 1 314
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,722评论 3 335
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,841评论 1 348
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,569评论 5 345
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,168评论 3 328
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,783评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,918评论 1 269
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,962评论 2 370
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,781评论 2 354

推荐阅读更多精彩内容