File tree 1 file changed +10
-8
lines changed
packages/react-router/lib 1 file changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -1043,17 +1043,19 @@ export function useNavigation() {
1043
1043
1044
1044
@category Hooks
1045
1045
*/
1046
- export function useRevalidator ( ) {
1046
+ export function useRevalidator ( ) : {
1047
+ revalidate : ( ) => Promise < void > ;
1048
+ state : DataRouter [ "state" ] [ "revalidation" ] ;
1049
+ } {
1047
1050
let dataRouterContext = useDataRouterContext ( DataRouterHook . UseRevalidator ) ;
1048
1051
let state = useDataRouterState ( DataRouterStateHook . UseRevalidator ) ;
1052
+ let revalidate = React . useCallback ( async ( ) => {
1053
+ await dataRouterContext . router . revalidate ( ) ;
1054
+ } , [ dataRouterContext . router ] ) ;
1055
+
1049
1056
return React . useMemo (
1050
- ( ) => ( {
1051
- async revalidate ( ) {
1052
- await dataRouterContext . router . revalidate ( ) ;
1053
- } ,
1054
- state : state . revalidation ,
1055
- } ) ,
1056
- [ dataRouterContext . router , state . revalidation ]
1057
+ ( ) => ( { revalidate, state : state . revalidation } ) ,
1058
+ [ revalidate , state . revalidation ]
1057
1059
) ;
1058
1060
}
1059
1061
You can’t perform that action at this time.
0 commit comments