您好,我想知道是否以及如何使用和实现不在类或功能组件内的 redux 操作。
我想实现这样的东西。
import { setPerson } from ./actions.js
export const registerPerson = (data) => {
/* here we do whatever we need to set register a person */
...
.then((res) => {
setPerson(res.data). <--- Here is the instance that I want to do.
}).catch(err => console.warn(err);
}
目标是将registerPerson
函数导入到 React 组件中,redux 操作将在导入的函数中触发。