Skip to content

Commit

Permalink
avoid desctructure
Browse files Browse the repository at this point in the history
  • Loading branch information
Timer committed Feb 17, 2020
1 parent 779bf29 commit 3cb654f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 3 additions & 2 deletions packages/next/client/link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ declare const __NEXT_DATA__: any

import React, { Children, Component } from 'react'
import { parse, resolve, UrlObject } from 'url'
import { PrefetchOptions } from '../next-server/lib/router/router'
import {
execOnce,
formatWithValidation,
Expand Down Expand Up @@ -205,11 +206,11 @@ class Link extends Component<LinkProps> {
})
}

prefetch(options: { priority?: boolean } = {}) {
prefetch(options?: PrefetchOptions) {
if (!this.p || typeof window === 'undefined') return
// Prefetch the JSON page if asked (only in the client)
const [href, asPath] = this.getPaths()
Router.prefetch(href, asPath, { priority: options.priority })
Router.prefetch(href, asPath, options)
prefetched[href] = true
}

Expand Down
6 changes: 5 additions & 1 deletion packages/next/next-server/lib/router/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ export type NextRouter = BaseRouter &
| 'isFallback'
>

export type PrefetchOptions = {
priority?: boolean
}

type RouteInfo = {
Component: ComponentType
props?: any
Expand Down Expand Up @@ -659,7 +663,7 @@ export default class Router implements BaseRouter {
prefetch(
url: string,
asPath: string = url,
options: { priority?: boolean } = {}
options: PrefetchOptions = {}
): Promise<void> {
return new Promise((resolve, reject) => {
const { pathname, protocol } = parse(url)
Expand Down

0 comments on commit 3cb654f

Please sign in to comment.