如何在 React Native 中重新渲染(刷新)底部标签栏?
How can I re-render(refresh) bottom tab bar in react native?
我正在为
import { create Bottom Tab Navigator } from '@react-navigation/bottom-tabs';
我想在通过调度操作从购物车组件中删除购物车项目后重新呈现底部选项卡,我关注的选项卡是购物车选项卡,
我还使用自定义组件从下面的状态获取购物车计数我正在共享底部选项卡图标的代码。
export class Cart Badge Icon extends Component {
constructor(props){
super(props);
}
render() {
return (
<>
<Image source={this.props.is-focused ? IMP_CONT.CART_ACTIVE :
MG_CONT.CART_INACTIVE} style={{ width: scale(25), height: scale(22) }} />
{this.props.counterproductive ?
(<View
>
<Text>{this.props.cart Count}
</Text>
</View>
) : null}
</>
)
}
}
cont map State To Props = (state) => ({
cart Has Product Flag: state.cart.cart Has Product,
cart Count: state.cart.cart Count,
})
export default connect(map State To Props)(Cart Badge Icon)
and i have import this component in my bottom Tab like this <Cart Badge Icon/>
经过一天我喜欢的解决方案,
我发送了一个接收 cartCount 的动作,我已经在 CartBadgeIcon 组件中获得了 cartCout。
export class Cart Badge Icon extends Component {
constructor(props){
super(props);
}
render() {
return (
<>
<Image source={this.props.is-focused ? IMP_CONT.CART_ACTIVE :
MG_CONT.CART_INACTIVE} style={{ width: scale(25), height: scale(22) }} />
{this.props.counterproductive ?
(<View
>
<Text>{this.props.cart Count}
</Text>
</View>
) : null}
</>
)
}
}
cont map State To Props = (state) => ({
cart Has Product Flag: state.cart.cart Has Product,
cart Count: state.cart.cart Count,
})
export default connect(map State To Props)(Cart Badge Icon)
and i have import this component in my bottom Tab like this <Cart Badge Icon/>
经过一天我喜欢的解决方案, 我发送了一个接收 cartCount 的动作,我已经在 CartBadgeIcon 组件中获得了 cartCout。