redux表单页面设置值。我将状态保存在本地存储中。页面重新加载后,直到单击完输入框后,我现在所拥有的才显示出来。为了实现这一目标,我应该使用哪种方法?任何教taught都很好。
export default reduxForm({
form: 'checkoutForm',
keepDirtyOnReinitialize: true,
enableReinitialize: true,
})(PaymentOptions);
答案 0 :(得分:0)
如果我正确理解手头的问题,那么我有个建议可能对您有用。
创建一个获取localStorage的动作创建者
export const getLocalStorageData = () => dispatch => {
const storage = localStorage.getItem('form_data')
dispatch(...update store here)
}
尝试连接initialValues
CheckoutForm = connect(
state => ({
initialValues: state.data // pull initial values from reducer
}),
{ data: getLocalStorageData } // bind getLocalStorageData action creator
)(CheckoutForm)