1
Fork 0
mirror of https://github.com/pds-nest/nest.git synced 2024-11-25 06:24:19 +00:00

🧊 Renamed inner resources variable to res

This commit is contained in:
Steffo 2021-05-23 18:24:24 +02:00
parent b2ad53d209
commit 1be5584de9
Signed by: steffo
GPG key ID: 6965406171929D01

View file

@ -114,7 +114,7 @@ export default function useBackendViewset(resourcesPath, pkName,
const retrieveResource = useCallback(
async (pk) => {
const refreshedResource = await apiRetrieve(pk)
setResources(resources => resources.map(resource => {
setResources(res => res.map(resource => {
if(resource[pkName] === pk) {
return refreshedResource
}
@ -128,7 +128,7 @@ export default function useBackendViewset(resourcesPath, pkName,
const createResource = useCallback(
async (data) => {
const newResource = await apiCreate(data)
setResources(resources => [...resources, newResource])
setResources(res => [...res, newResource])
return newResource
},
[apiCreate],
@ -137,7 +137,7 @@ export default function useBackendViewset(resourcesPath, pkName,
const editResource = useCallback(
async (pk, data) => {
const editedResource = await apiEdit(pk, data)
setResources(resources => resources.map(resource => {
setResources(res => res.map(resource => {
if(resource[pkName] === pk) {
return editedResource
}
@ -151,7 +151,7 @@ export default function useBackendViewset(resourcesPath, pkName,
const destroyResource = useCallback(
async (pk) => {
await apiDestroy(pk)
setResources(resources => resources.filter(resource => resource[pkName] !== pk))
setResources(res => res.filter(resource => resource[pkName] !== pk))
return null
},
[apiDestroy, pkName],