【发布时间】:2017-09-17 17:00:22
【问题描述】:
使用带有此代码的 RN 标准 截图: 如上所述“state.debug”是布尔类型: 问题 - 为什么布尔道具不显示/渲染?class ClassName extends Component {
static propTypes = {
debug: PropTypes.bool
};
render() {
return (
<View style={...}>
<Text>Debug mode: {this.props.debug}</Text>
</View>
)
}
}
const mapStateToProps = (state) => {
console.log(typeof(state.debug); //boolean
return {
debug: state.debug
}
}
export default connect(mapStateToProps)(ClassName);
console.log(typeof(state.debug)); //boolean
【问题讨论】:
-
"debug: String(state.debug)" 解决了这个问题,但问题依然存在。
标签: react-native