useShow
useShow is an extended version of useOne. It supports all the features of useOne and adds some extra features.
It is useful when you want to fetch a single record from the API. It will return the data and some functions to control the query.
Usage
The useShow hook does not expect any properties. By default, it will try to read the resource and id values from the current URL. It will be passed to the getOne method from the dataProvider as a parameter.
If you define resource and id on the hook, when these properties are changed, the useShow hook will trigger a new request.
Realtime Updates
This feature is only available if you use a Live Provider.
When the useShow hook is mounted, it will call the subscribe method from the liveProvider with some parameters such as channel, resource etc. It is useful when you want to subscribe to live updates.
Refer to the liveProvider documentation for more information →
Properties
resource
Default: It reads the
resourcevalue from the current URL.
It will be passed to the getOne method from the dataProvider as parameter via the useOne hook.
The parameter is usually used as an API endpoint path.
It all depends on how to handle the resource in the getOne method.
See the creating a data provider section for an example of how resources are handled.
useShow({
  resource: 'categories',
})