使用默认道具渲染FlatList时出错无法执行' importScripts' on' WorkerGlobalScope'

时间:2017-10-29 06:11:24

标签: reactjs react-native

当我在react-native app中导入和使用flatList时,我收到此错误。

import { Text, FlatList  } from 'react-native'

我的FlatList组件:

<FlatList
 data={responseData}
 renderItem={({node}) => <Text style={} >{node.nameWithOwner}</Text>}/>

渲染没有任何道具的FlatList时,我没有收到错误 来自世博会模拟器屏幕。

当只使用数据道具而不是renderItem道具时,我得到renderItem is not a function

img_20171029_083459

abi21_0_0.com.facebook.react.common .JavascriptException: Failed 
to execute 'importScripts' on 'WorkerGlobalScope': The script at 
'http://1 92.1 68.0.1 3:19001/ node_modules/react-native-
scripts/build/bin/crna-entry.bundle?platform=android&dev=true&strict=false&minify=false&hot=false&assetPlugin=expo/tools/ hashAssetFiles' failed to load.
Failed to execute 'importScripts' on 'WorkerGlobalScope': The script 
at 'http:// 192.168.0.13:19001/node_modules/reactnative-
scripts/build/bin/crna-entry.bundle?platform=android&dev=true&strict=false&minify=faIse&hot=false&assetPlugin=
expoltoolsl hashAssetFiles' failed to load.
loadApplicationScript WebsocketJavaScriptExecutor.java:173
run NativeRunnable.java

像这样的facebook / react-native#13558以及此https://github.com/facebook/react-native/issues/6035https://github.com/bnovf/react-native-github-graphql-app/issues/3

这是FlatList本身的问题吗?

1 个答案:

答案 0 :(得分:0)

通过改变renderItem prop函数来解决

     <FlatList
      data={responseData}
      renderItem={({item}) => <Text >{item.node.nameWithOwner}</Text>}
    />