usePrefetchResource
basic
Hook that returns same actions and data as useResource hook. In additional usePrefetchResource hook will:
- send initial Request on mount
- terminate pending request on unmount
- clear resource on unmount
- returns aditional
initialLoadingindicator
usePrefetchResource accepts 2 arguments:
1. resourceConfig. Resource config
2. prefetchConfigs. Additional configurations to customize prefetch logic.
caution
In case you need to send HTTP request to get data to render Component, we strongly recommend to use usePrefetchResource hook. These will cover the most common scenarios and let you avoid duplicating code.
prefetchConfigs
filters
Payload to pass to initial API Request
method
String GET|POST. Default GET. String configuration to control initial request HTTP Method.
destroyOnUnmount
Boolean flag. Default true. Flag to control whenever to delete resource data on component unmount.
In case you need to save Component data even if Component was removed from the dom (in memory cache)