升级react-native-elements后Button组件属性报错,求替代方案
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
containerStylefor 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.
相关产品推荐
相关产品推荐

