Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mikezerosix opened this issue Jan 3, 2025 · 0 comments

Comments

@mikezerosix
Copy link

mikezerosix commented Jan 3, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant