-
Suppose you have a Show page, but you want to pass a custom resourceParam const { showId } = useShow<Example>({ resource: 'api/V1/Example' })
Is that the default intended behavior?I was hesitant to submit a bug ticket as it might be a feature. It seemed unintuitive to me, that it would override id if you pass a different resource name. My workaround is this: const { useParams } = useRouterContext()
const { id } = useParams<ResourceRouterParams>()
const { queryResult, showId } = useShow<Example>({ resource: 'api/V1/Example', id: id })
And I'm able to fetch the data, I looked at useShow internal code link const defaultId = !resourceFromProp || resourceFromProp === routeResourceName ? id ?? idFromRoute : id Default would not be set if you pass a custom resource |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Hey @vinclou, that condition is added to support the cases like you use the The condition works as an enable/disable switch for We've recently had a discussion on updating this logic since it's limiting the use cases and actually causing a confusion on when to use I wonder about your use case though, just a wild guess; can you achieve what you are trying to do by just using |
Beta Was this translation helpful? Give feedback.
Hey @vinclou, that condition is added to support the cases like you use the
useShow
hook twice, one for using it to fetch the data from url params (likeposts/1
) and one for fetching thecategories/15
data whichid
is coming from the response ofposts/1
.The condition works as an enable/disable switch for
useShow
to handle asynchronously using the id15
forcategories
resource.We've recently had a discussion on updating this logic since it's limiting the use cases and actually causing a confusion on when to use
useShow
and when to useuseOne
. I think we will cover more cases by allowingid
only andresource
only prop changes and leavingcategories/15
calls inposts/1
page touseOne
.I wo…