好吧,我发现如果您在
lifecycle方法之后移动
withState方法,则可以通过访问设置器
this.props.setterFunction。就我而言,这是我一直在寻找的解决方案:
const enhance = compose( withState('isAvailable', 'setIsAvailable', false), withState('isReady', 'setIsReady', false), lifecycle({ componentDidMount() { myCall .getResponse([productId]) .then(products => { this.props.setIsReady(true); }); }, }), mapProps(({ setIsAvailable, setIsReady, ...state, }) => ({ onLogoutTouchTap: () => { ...


