File tree Expand file tree Collapse file tree 2 files changed +4
-6
lines changed
Expand file tree Collapse file tree 2 files changed +4
-6
lines changed Original file line number Diff line number Diff line change @@ -228,7 +228,6 @@ export type KeyedMutator<Data> = (
228228 data ?: Data | Promise < Data > | MutatorCallback < Data > ,
229229 opts ?: boolean | MutatorOptions < Data >
230230) => Promise < Data | undefined >
231- // Public types
232231
233232export type SWRConfiguration <
234233 Data = any ,
Original file line number Diff line number Diff line change @@ -440,9 +440,7 @@ export const useSWRHandler = <Data = any, Error = any>(
440440 // By using `bind` we don't need to modify the size of the rest arguments.
441441 // Due to https://github.com/microsoft/TypeScript/issues/37181, we have to
442442 // cast it to any for now.
443- async ( ...args ) => {
444- return internalMutate < Data > ( cache , keyRef . current , ...args )
445- } ,
443+ internalMutate . bind ( UNDEFINED , cache , keyRef . current ) as any ,
446444 // eslint-disable-next-line react-hooks/exhaustive-deps
447445 [ ]
448446 )
@@ -459,9 +457,10 @@ export const useSWRHandler = <Data = any, Error = any>(
459457 } )
460458
461459 useIsomorphicLayoutEffect ( ( ) => {
462- if ( _key && key ) KEYS . add ( _key )
460+ const isTruthyKey = _key && key && ! isFunction ( _key )
461+ if ( isTruthyKey ) KEYS . add ( _key )
463462 return ( ) => {
464- if ( _key && key ) KEYS . delete ( _key )
463+ if ( isTruthyKey ) KEYS . delete ( _key )
465464 }
466465 } , [ _key ] )
467466
You can’t perform that action at this time.
0 commit comments