-
Notifications
You must be signed in to change notification settings - Fork 24.8k
Closed
Labels
Resolution: LockedThis issue was locked by the bot.This issue was locked by the bot.
Description
Is this a bug report?
Yes
Have you read the Contributing Guidelines?
Yes
Environment
Environment:
OS: macOS Sierra 10.12.6
Node: 8.7.0
Yarn: 1.2.1
npm: 5.4.2
Watchman: 4.7.0
Xcode: Xcode 9.1 Build version 9B55
Android Studio: 3.0 AI-171.4443003
Packages: (wanted => installed)
react: 16.0.0 => 16.0.0
react-native: ^0.50.3 => 0.50.3
Steps to Reproduce
- have a
TochableOpacity
with propdisabled = true
and styleopacity: 0.5
- toggle disabled flag to
false
and style toopacity: 1
Expected Behavior
Opacity of component should change from 0.5 to 1
Actual Behavior
Opacity remains the same unless you press the component (which still looks like disabled)
Reproducible Demo
https://snack.expo.io/rJhh9F8Zz
import React, { Component } from 'react';
import { Text, View, StyleSheet, TouchableOpacity, Button } from 'react-native';
import { Constants } from 'expo';
export default class App extends Component {
state = {
isDisabled: true,
}
onPressBox=()=>{
this.setState({
isDisabled: !this.state.isDisabled,
})
}
render() {
const { isDisabled } = this.state
return (
<View style={styles.container}>
<Text>
Example of bug in TouchableOpacity.
The green box is disabled initially.
If you press "toggle `disabled`" is it supposed become fully opaque.
It will not change opacity until you tap it.
</Text>
<View style={styles.column}>
<View style={styles.row}>
<TouchableOpacity
style={isDisabled?styles.disabled:styles.enabled}
disabled={isDisabled}>
<View style={styles.box}>
<Text>{isDisabled ? "Disabled" : "Enabled"}</Text>
</View>
</TouchableOpacity>
<Button title="toggle `disabled`" onPress={this.onPressBox} />
</View>
</View>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
paddingTop: Constants.statusBarHeight,
backgroundColor: 'white',
},
enabled: {
opacity: 1,
},
disabled: {
opacity: 0.3,
},
row: {
flexDirection: 'row',
},
column: {
flexDirection: 'column',
},
box: {
width: 100,
height: 100,
backgroundColor: 'green',
},
});
palerdot, afilp, riwu, drpgdigital, s-low and 14 morelwinkyawmyat, MinskLeo and dijonneto
Metadata
Metadata
Assignees
Labels
Resolution: LockedThis issue was locked by the bot.This issue was locked by the bot.