You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

升级react-native-elements后Button组件属性报错,求替代方案

Fixing Missing Button Props After Upgrading react-native-elements to v1.1

Hey there! I’ve dealt with my fair share of react-native-elements upgrade gotchas, so let’s walk through replacing those missing props for your Button component:

Here’s how to map your old props to the v1.1 equivalents:

  • underlayColor: This prop moved to touchableStyle (since it controls the underlying Touchable component’s behavior). Replace it with:
    touchableStyle={{underlayColor: styles.palette.transparent}}
    
  • containerViewStyle: This was renamed to containerStyle for consistency across the library. Simply update the prop name:
    containerStyle={styles.modal.actionButtonContainer}
    
  • textStyle: Good news—this prop still exists in v1.1! Your existing array-based style (with conditional color) should work exactly as it did before. No changes needed here beyond keeping it assigned to textStyle.

Full Modified Button Component

Here’s your updated code with all props replaced correctly:

<Button
  buttonStyle={{backgroundColor: styles.palette.transparent}}
  onPress={this.connectWithEmail}
  title={I18n.t('CONFIRM')}
  disabled={!this.state.password || !this.state.email}
  disabledStyle={styles.modal.actionButtonDisabled}
  touchableStyle={{underlayColor: styles.palette.transparent}}
  containerStyle={styles.modal.actionButtonContainer}
  textStyle={[
    styles.modal.actionButtonText,
    {color: (this.state.password && this.state.email) ? styles.palette.secondary : styles.palette.textLight}
  ]}
/>

A quick tip for future upgrades: If you can’t find prop changes in the official docs, check the component’s TypeScript definitions (look for ButtonProps in the library’s types folder) or peek at the Button component source code—this often reveals renamed or moved props faster than docs do.

内容的提问来源于stack exchange,提问作者Jaroslaw K.

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.13 07:22:26