【问题标题】:Warning: Failed prop type: Invalid props.style key 'resizeMode' supplied to 'RCTView'警告:道具类型失败:提供给“RCTView”的道具样式键“resizeMode”无效
【发布时间】:2017-12-26 00:30:29
【问题描述】:

我正在使用 react-native-elements 并且收到两个相同的警告,一个针对 View,另一个针对 RCTView。

当我用其他东西(只是一个简单的视图)替换 Tile 时,它​​很好。

警告如下:

警告:失败的道具类型:无效的 props.style 键“resizeMode” 提供给“RCTView”

警告:失败的道具类型:无效的 props.style 键“resizeMode” 提供给“视图”

这是有问题的代码:

 return (

  <ScrollView>
    {events.map((event) => (
    <Tile
     key={event.event_id}
        imageSrc={{ uri: event.picture.large }}
        title={`${event.title.toUpperCase()}`}
        onPress={() => this.onLearnMoreEvent(event)}
        contentContainerStyle={{height: 80}}
      >
        <View style={{flex: 1, flexDirection: 'row', justifyContent: 'space-between'}}>
          <Text>{`${event.location.city}, ${event.start_date} `}</Text>
          <Text>Music</Text>
        </View>
      </Tile>

        ))}


  </ScrollView>
);

【问题讨论】:

  • 我在您的代码中没有看到任何对 resizeMode 的引用,它是否在其他地方使用过?上面组件的父组件是否设置了高度,或者它是一个弹性容器?根据facebook.github.io/react-native/docs/scrollview.html,ScrollView 组件必须有一个有界的高度才能工作。
  • 这是一个标签,这是我唯一能想到的。事情是它直到昨天都运行良好......
  • @DoronGoldberg 我今天也第一次看到同样的错误......除了我没有在我的应用程序的任何地方使用标签。我只在 ios 中看到这个错误,而不是在 android 中。你在这两个平台上都看到了吗?

标签: javascript reactjs react-native react-native-ios


【解决方案1】:

虽然删除 resizeMode 会起作用,但正确的答案是将其传递给新的道具 imageStyle。

修复将在下一个版本的 react-native-elements 中:

Tile: Warning: Failed prop type: Invalid props.style key 'resizeMode' supplied to 'View'

【讨论】:

    【解决方案2】:

    找到解决方案:

    编辑

    node_modules/react-native-elements/src/tile/Tile.js

    删除

    resizeMode: '覆盖'

    来自:

      imageContainer: {
          alignItems: 'center',
          justifyContent: 'center',
          resizeMode: 'cover',
          backgroundColor: '#ffffff',
          flex: 2,
        },
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-12-17
      • 1970-01-01
      • 1970-01-01
      • 2020-01-22
      • 1970-01-01
      • 2018-04-23
      • 2021-01-18
      • 1970-01-01
      相关资源
      最近更新 更多