简体   繁体   English

如何以Redux形式使用Action Creators

[英]How to use Action Creators in Redux-form

I want change the value of field 'Buffer' in my redux-form 'payForm' so in a dispacth i want use relative action creator 我想在Redux形式的“ payForm”中更改字段“ Buffer”的值,因此我想使用相对动作创建器

import {  actions } from 'react-redux-form'
....
store.dispatch(actions.change('payForm','Buffer', bufferValue);

doesn't work, fail silently. 不起作用,静默失败。

Help !!! 救命 !!!

if you want to change value of a particular registered fields then you can follow this approach.... 如果您想更改特定注册字段的值,则可以采用这种方法。

import { change } from 'redux-form';

import action creator change... and then you can dispatch change action as.. 导入动作创建者更改...,然后您可以按以下方式分发更改操作:。

store.dispatch(change('payForm', 'Buffer', bufferValue));

for more refer redux-form documentation https://redux-form.com/7.2.0/docs/api/actioncreators.md/ 有关更多信息,请参考redux-form文档https://redux-form.com/7.2.0/docs/api/actioncreators.md/

You can use change from your props which will fire the corresponding action, see here 您可以使用props change来触发相应的动作,请参见此处

So if you have a Field 所以如果你有一个Field

<Field name="Buffer" component="input" />

inside your form component, you can change it by simply call 在表单组件内部,只需调用即可更改它

this.props.change("Buffer", bufferValue);

This will in turn call the proper action creator. 这将依次调用适当的操作创建者。 See this working example 请参阅此工作示例

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM