mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-06 15:57:13 +00:00
Update SingletonRouter type to include ready and readyCallback funcs
This commit is contained in:
Vendored
+2
-3
@@ -10,9 +10,6 @@ export interface EventChangeOptions {
|
||||
|
||||
export type RouterCallback = () => void;
|
||||
export interface RouterProps {
|
||||
readyCallbacks: RouterCallback[];
|
||||
ready(cb: RouterCallback): void;
|
||||
|
||||
// router properties
|
||||
readonly components: {
|
||||
[key: string]: { Component: React.ComponentType<any>; err: any };
|
||||
@@ -55,6 +52,8 @@ export interface RouterProps {
|
||||
|
||||
export interface SingletonRouter {
|
||||
router: RouterProps;
|
||||
readyCallbacks: RouterCallback[];
|
||||
ready(cb: RouterCallback): void;
|
||||
}
|
||||
|
||||
export function withRouter<T extends {}>(
|
||||
|
||||
@@ -2,10 +2,10 @@ import Router, * as r from "next/router";
|
||||
import * as React from "react";
|
||||
import * as qs from "querystring";
|
||||
|
||||
Router.router.readyCallbacks.push(() => {
|
||||
Router.readyCallbacks.push(() => {
|
||||
console.log("I'll get called when the router initializes.");
|
||||
});
|
||||
Router.router.ready(() => {
|
||||
Router.ready(() => {
|
||||
console.log(
|
||||
"I'll get called immediately if the router initializes, or when it eventually does.",
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user