Skip to content

useNewResource throws "Cannot read properties of undefined (reading 'data')" on submit() #494

@mikezerosix

Description

@mikezerosix

With react-ketting: 4.0.10 I am getting error :

react-ketting.js?v=61b31b9f:379 Uncaught TypeError: Cannot read properties of undefined (reading 'data')
at useNewResource (react-ketting.js?v=61b31b9f:379:47)

from function useNewResource line 114
data: useResourceResult.resourceState.data,

It seems resourceState is undefined.

I am using
const {loading, error, resourceState, setResourceState, submit, data, setData, resource} = useNewResource("/api/eprs", { initialData: {}, refreshOnStale: true});
and calling submit(); seems to work OK. It creates POST request that returns 201 and then it creates GET request that returns 200 and data response but then the react page throws error from within react-ketting.

There are no documentation or example how to use the useNewResources hook. Is there something that needs to be doen the the promise returned by submit() ?

Also initialing the useNewResource hook, the loading is always true.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions