Upgrading from 4 to 5
Deprecation Removals
These previously deprecated members have been removed:
Resource.getKey() -> Resource.key
Resource.getEntitySchema() -> Resource
Other breaking changes
yarn add @rest-hooks/test@2 @rest-hooks/legacy@2
Network Definitions (Resource/FetchShape, etc)
FetchShape: {type: 'delete'} -> { type: 'mutate', schema: new schemas.Delete(this) }
Validation Errors: `This is likely due to a malformed response`
Imports
import { reducer, NetworkManager } from '@rest-hooks/core'
Managers
These only apply if you have a custom Manager
action.meta.url -> action.meta.key
getState()
Cache Lifetime Policy
useInvalidator() triggers suspense
`delete` suspends instead of throwing 404
Missing entities suspend
invalidIfStale
Upgrading from beta versions to final
The last breaking changes introduced to rest-hook
were in delta.0
where TTL
and deletes were reworked. If you are on a more recent beta (i
, j
, k
, rc
),
upgrades should be as simple as updating the version.
If this is not the case, please report a bug.
Deprecations
After a successful upgrade, it is recommended to adopt the modern practices.
Resource.fetchOptionsPlugin() -> Resource.getFetchInit()
Resource.getFetchOptions() -> Resource.getEndpointExtra()
Resource.asSchema() -> Resource
@rest-hooks/legacy
For v5 of Rest Hooks, the existing Resource
and SimpleResource
classes will
be exported.
In v6, this will no longer be the case. However, they will continue to live in @rest-hooks/legacy
, allowing
easy safe upgrade to v6 by simply changing the import path. However, it is still recommended to
try to migrate to @rest-hooks/rest
as this is the future. v1 of @rest-hooks/rest will be the easiest to
start with.
yarn add @rest-hooks/legacy
@rest-hooks/rest
Rest Hooks is protocol agnostic, so the REST/CRUD specific class Resource
will eventually be fully deprecated and removed. @rest-hooks/rest
is intended as its
replacement. Other supplementary libraries like @rest-hooks/graphql
could be
added in the future, for intance. This is also beneficial as these libraries
change more frequently than the core of rest hooks.