mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-03 22:37:03 +00:00
[next-server v8.1] Add useRouter() hook (#35058)
* [next-server] Add useRouter() hook * Add a test for useRouter * Add missing semicolon * Bump version to 8.1 * RouterProps → SingletonRouter * SingletonRouter → RouterProps 😅 * Update types/next-server/router.d.ts As suggested by @resir014 Co-Authored-By: kachkaev <alexander@kachkaev.ru> * Fix linting
This commit is contained in:
committed by
Wesley Wigham
parent
492d259a46
commit
72a04fcfed
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Type definitions for next-server 8.0
|
||||
// Type definitions for next-server 8.1
|
||||
// Project: https://github.com/zeit/next.js/packages/next-server
|
||||
// Definitions by: Drew Hays <https://github.com/dru89>
|
||||
// Brice BERNARD <https://github.com/brikou>
|
||||
|
||||
Vendored
+3
@@ -96,5 +96,8 @@ export function withRouter<T extends {}, Q = DefaultQuery>(
|
||||
Component: React.ComponentType<T & WithRouterProps<Q>>
|
||||
): React.ComponentType<Omit<T, keyof WithRouterProps<Q>>>;
|
||||
|
||||
// tslint:disable-next-line no-unnecessary-generics
|
||||
export function useRouter<Q = DefaultQuery>(): RouterProps<Q>;
|
||||
|
||||
declare const Router: SingletonRouter;
|
||||
export default Router;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import Router, { withRouter, WithRouterProps } from "next-server/router";
|
||||
import Router, { useRouter, withRouter, WithRouterProps } from "next-server/router";
|
||||
import * as React from "react";
|
||||
import * as qs from "querystring";
|
||||
|
||||
@@ -154,4 +154,9 @@ const TestSFC3 = withRouter(({ router }) => {
|
||||
return <div>{router && router.query && router.query.test}</div>;
|
||||
});
|
||||
|
||||
const TestHook = (() => {
|
||||
const router = useRouter();
|
||||
return <div>{router && router.query && router.query.test}</div>;
|
||||
});
|
||||
|
||||
const res4 = <TestSFC3 />;
|
||||
|
||||
Reference in New Issue
Block a user