You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a page that edits a strapi single type using the useForm hook
after I have upgraded the "@refinedev/core" package this page has stopped working and throwing an Error in the browser console that "id" is not provided.
I cannot provide an id because I want to edit a strapi single type instance and strapi's rest api does not accept an id in the url path.
until now I passed an empty string any everything worked fine.
I researched and it looks like this bug (or an api-breaking feature...) is because of this commit in this line
Steps To Reproduce
use the useForm or useUpdate hooks
pass an empty string as the id argument
Expected behavior
the hook does not throws an error and sends the request using the data provider
Packages
@refinedev/core
Additional Context
I am importing the "useForm" hook from @refinedev/antd but I don't think that the problem is there...
The text was updated successfully, but these errors were encountered:
Hi @alicanerdurmaz!
thanks for responding this fast...
Looks like my explanation wasn't detailed enough 😅
I am using typescript, and I am passing an empty string as the id, something like this:
const{...}=useForm({id: '', ...});
and typescript allowed it...
The problem is probably because !"" evaluates to true then the "missing id" error is thrown.
I am using an empty string because in strapi-v4 data provider the id part of the api requests is empty, then then the path ends with ...<resource>/ and it works with the single types rest api paths of strapi.
The possible solution might be checking for null/undefined value in this if statement...
Thank you very much!
- if (!id) throw missingIdError;+ if (typeof id === "undefined") throw missingIdError;
We also believe that making the ID optional is the right approach, but implementing this change affects several parts of the core. We plan to introduce this improvement with Refine 5.
Describe the bug
I have a page that edits a strapi single type using the
useForm
hookafter I have upgraded the "@refinedev/core" package this page has stopped working and throwing an Error in the browser console that "id" is not provided.
I cannot provide an id because I want to edit a strapi single type instance and strapi's rest api does not accept an id in the url path.
until now I passed an empty string any everything worked fine.
I researched and it looks like this bug (or an api-breaking feature...) is because of this commit in this line
Steps To Reproduce
useForm
oruseUpdate
hooksExpected behavior
the hook does not throws an error and sends the request using the data provider
Packages
Additional Context
I am importing the "useForm" hook from @refinedev/antd but I don't think that the problem is there...
The text was updated successfully, but these errors were encountered: