如何進(jìn)行React組件單元測試
如何進(jìn)行React組件單元測試
ibeautiful
2019-03-02 15:03:07
TA貢獻(xiàn)1853條經(jīng)驗(yàn) 獲得超9個(gè)贊
可以在子組件添加一個(gè)componentWillRecieveProps周期,在里面獲取到即將接收的props。如下: componentWillReceiveProps(nextProps) { this.setState({ A: nextProps.A }); }
舉報(bào)