constructor(props, context) {super(props);this.state = {ShowVoucher: false }我想更改showVoucher的狀態。無需重新渲染組件。我已經嘗試過這樣componentDidUpdate(prevState) {if(prevState.showVoucher!= this.state.showVoucher){ this.setState({ ShowVoucher: false})} }但是我的代碼陷入了無限循環。我該如何解決?任何其他解決方案都歡迎。
在React js中如何在不重新渲染組件的情況下使用setstate?
素胚勾勒不出你
2021-05-11 17:37:57