The properties in the react-native section seem no longer compatible with the SWRConfiguration type.
In the docs you have the example of
<SWRConfig
value={{
provider: () => new Map(),
isOnline() {
/* Customize the network state detector */
return true
},
isVisible() {
/* Customize the visibility state detector */
return true
},
initFocus(callback) {
/* Register the listener with your state provider */
},
initReconnect(callback) {
/* Register the listener with your state provider */
}
}}
>
This however misaligns with the exported type of SWRConfiguration as the following properties are missing
provider
initFocus
initReconnect
Upon further inspection of the exported index.d.ts, the missing properties come from type Config which is however not exported.
Unless there's an internal reason for not exposing these methods (which seems contradictory with the react-native documentation) the exported type for SWRConfig should be Config instead
Furthermore when importing the component SWRConfig it just defaults to :any, seems a resolution issue with directly importing react over just importing it's types in the SWRConfig definition. import ReactExports from 'react'
Sorry, didn't realize when clicking on posting issue referral actually posts on the specific docs repo. Closing this issue, adding issue to SWR core repo + PR fix.
The properties in the
react-native
section seem no longer compatible with theSWRConfiguration
type.In the docs you have the example of
This however misaligns with the exported type of
SWRConfiguration
as the following properties are missingprovider
initFocus
initReconnect
Upon further inspection of the exported
index.d.ts
, the missing properties come from typeConfig
which is however not exported.where
ProviderConfiguration
is defined asUnless there's an internal reason for not exposing these methods (which seems contradictory with the
react-native
documentation) the exported type forSWRConfig
should beConfig
insteadFurthermore when importing the component
SWRConfig
it just defaults to:any
, seems a resolution issue with directly importing react over just importing it's types in the SWRConfig definition.import ReactExports from 'react'