Skip to main content
Version: v9.0.0(Outdated)

getShouldClearState

Determines whether state should be cleared when the cache key changes.

"clean" — always clear​

"preserve" — never clear​

"auto" — clear when the resource identity changed (URL params), preserve when only query params changed

In the "auto" mode the identity is read from the cache keys, which is not reliable for custom cache keys and for query params containing underscores - compare the requests with getRequestIdentity when they are available.


Import
import { getShouldClearState } from "@hyper-fetch/react"

Parameters​

getShouldClearState(mode: auto | preserve | clean, oldCacheKey: string, newCacheKey: string)
Parameters
NameTypeDescription
mode
auto | preserve | clean
oldCacheKey
string
newCacheKey
string

Returns​

boolean