【发布时间】:2019-01-22 16:11:07
【问题描述】:
我想知道将带有自定义获取和类型(不是更新)的自定义操作传递给 startUndoable 是否可行。
或者是否有可能以某种方式在 meta 中定义具有值的模式,并基于此模式重新渲染视图?
在这种情况下,IMPORT 仅使用固定值更新数据库中的一个属性。
这是动作:
export const importParcel = ({ id }) => ({
type: IMPORT_PARCEL,
payload: {
id
},
meta: {
resource: 'parcels',
fetch: IMPORT,
refresh: true,
onSuccess: {
notification: {
body: 'Parcel Imported',
level: 'info'
}
},
onFailure: {
notification: {
body: 'Error: Import failed',
level: 'warning'
}
}
}
});
这是处理程序:
fetchUtils
.fetchJson(`/${resource}/import/${params.id}`, {
method: 'PUT',
headers: getAuthenticationHeaders()
})
.then(res => ({ data: res.json }));
感谢您的帮助! :)
【问题讨论】:
标签: javascript reactjs react-admin