我想创建一个以数组作为参数的Action,但这不输入check:
export const action_organizations_available = createAction(
CoreActionTypes.ORGANIZATIONS_AVAILABLE,
props<Organization[]>()
);
我得到props(): "arrays are not allowed in action creators"
。当类型不是数组时,它可以正常工作。
使用props<{ organizations: Organization[] }>
有效,但我想知道这是否是最佳实践。
期望数组作为操作中的参数时的最佳实践是什么?
您必须将其包装到一个对象中:
export const action_organizations_available = createAction(
CoreActionTypes.ORGANIZATIONS_AVAILABLE,
props<{ organizations: Organization[] }>()
);