动作名称是 redux 形式的 public API 的一部分吗?
Are action names part of the public API in redux-form?
首先,我不完全确定我在 React/Redux 应用程序中安装的大多数第三方软件包的操作中的 @@
前缀是什么意思——如果它们的意思是 "private",那么我的问题的答案就很明显了。我在 Chrome.
的 Redux devtools 扩展中看到了它们
如果它只是一个范围约定 @@<package>/<action>
,那么我有一个关于 redux-form
包中的操作的具体问题。动作显然是 not documented,所以我 不确定我是否可以在 my reducers 中安全地使用它们而不用担心破坏变化。
有关更多上下文以防我的方法完全错误(仍在找出模式):我想删除注册表单并在成功完成后显示一条成功消息。 redux-form
调度类型为 @@redux-form/SET_SUBMIT_SUCCEEDED
的操作,meta.form
告诉我这是我命名为 register
的表单。所以我会在我的 RegisterPage
reducer 中使用它来设置一个布尔值 isSuccess
并使用它来更改视图。
如果没有明确记录它们,我会认为它们是私有的,不会直接使用它们。尽管没有在任何地方正式声明,@@
前缀通常表示不应由其他 reducer 代码处理的私有操作。我认为它起源于 @@redux/INIT_{random string}
动作(关于命名的讨论可以在这个 github thread 中找到):
In the new docs (#140) we should clarify that any actions prefixed
with @@ are not meant to be handled. For example, you should never try
to handle @@INIT.
在redux code itself中也明确说明了隐私:
/**
* These are private action types reserved by Redux.
* For any unknown actions, you must return the current state.
* If the current state is undefined, you must return the initial state.
* Do not reference these action types directly in your code.
*/
对于您的具体问题:您可以提供 onSubmitSuccess function to the HOC and dispatch your own action to update your own reducer or you could directly depend on the redux form state and get this boolean flag via the hasSubmitSucceeded selector。我个人认为第二种选择更好,因为它不会在您的商店中引入冗余状态 - redux 表单已经存储了表单是否已成功提交的信息,您自己在另一个 sub-reducer 中这样做可能会导致这两个布尔值无意中偏离。
首先,我不完全确定我在 React/Redux 应用程序中安装的大多数第三方软件包的操作中的 @@
前缀是什么意思——如果它们的意思是 "private",那么我的问题的答案就很明显了。我在 Chrome.
如果它只是一个范围约定 @@<package>/<action>
,那么我有一个关于 redux-form
包中的操作的具体问题。动作显然是 not documented,所以我 不确定我是否可以在 my reducers 中安全地使用它们而不用担心破坏变化。
有关更多上下文以防我的方法完全错误(仍在找出模式):我想删除注册表单并在成功完成后显示一条成功消息。 redux-form
调度类型为 @@redux-form/SET_SUBMIT_SUCCEEDED
的操作,meta.form
告诉我这是我命名为 register
的表单。所以我会在我的 RegisterPage
reducer 中使用它来设置一个布尔值 isSuccess
并使用它来更改视图。
如果没有明确记录它们,我会认为它们是私有的,不会直接使用它们。尽管没有在任何地方正式声明,@@
前缀通常表示不应由其他 reducer 代码处理的私有操作。我认为它起源于 @@redux/INIT_{random string}
动作(关于命名的讨论可以在这个 github thread 中找到):
In the new docs (#140) we should clarify that any actions prefixed with @@ are not meant to be handled. For example, you should never try to handle @@INIT.
在redux code itself中也明确说明了隐私:
/**
* These are private action types reserved by Redux.
* For any unknown actions, you must return the current state.
* If the current state is undefined, you must return the initial state.
* Do not reference these action types directly in your code.
*/
对于您的具体问题:您可以提供 onSubmitSuccess function to the HOC and dispatch your own action to update your own reducer or you could directly depend on the redux form state and get this boolean flag via the hasSubmitSucceeded selector。我个人认为第二种选择更好,因为它不会在您的商店中引入冗余状态 - redux 表单已经存储了表单是否已成功提交的信息,您自己在另一个 sub-reducer 中这样做可能会导致这两个布尔值无意中偏离。