0
技術:使用react,Redux,Redux窗體(FieldsArray),MongoDB。
我有實體的名單,我要做到以下幾點:Redux窗體 - 創建操作的同步窗體
我想創建一個實體 - >從服務器獲取回一個實體_id - 與當時的實體和_id>更新專門店。
我該怎麼做?
actions.js
export function createEntity(entity) {
return function (dispatch) {
dispatch(createEntityStart());
return axios.post(
'http://localhost:3000/api/users',
entity,
)
.then(function (response) {
dispatch(createEntitySuccess(response.entityWithId));
}).catch(function (response) {
dispatch(createEntityError(response.data));
});
};
}
我也做了fields.push({}) - 得到了在組件的新實體。 現在我想發佈一個跟隨返回實體的新實體(帶ID)。 我現在需要在商店某個地方用Id保存實體。
應該怎麼做?
我在店裏有:
- 形式
- MyFormName
- 值
- 初始
- registeredFields
- 值
- MyFormName
我不確定你的意思,只需將它更新回正確位置的表單值即可。您是否想要將某個實體ID存儲在某個特定表單的某個位置的redux表單中? –
感謝您的回答 - 編輯此問題以使其更加清晰 – chenop