【发布时间】:2018-10-12 11:10:36
【问题描述】:
我在 iOS 和 Android 上使用过 react-native-maps,我也在地图上使用了很多标记。
所以我真的需要尽可能快地渲染视图。
在以下这些方式中,最快的方式是什么?
仅限 Redux
const mapStateToProps = (state) => ({
a: state.a
});
render() {
return (
this.props.a ? (<View>isA</View>) : (<View>isNotA</View>)
);
}
来自 Redux 的反应状态
state = { a: false }
static getDerivedStateFromProps(nextProps, prevState) {
if (nextProps.a !== prevState.a) {
return ({ a: nextProps.a })
}
}
render() {
return (
this.state.a ? (<View>isA</View>) : (<View>isNotA</View>)
);
}
【问题讨论】:
标签: reactjs react-native redux