Skip to content

Commit

Permalink
feat(client-only-path): added client only path option for nextjs router.
Browse files Browse the repository at this point in the history
  • Loading branch information
BowlingX committed Jul 9, 2021
1 parent b71a406 commit 739a007
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/lib/adapters/Next.js.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,8 @@ interface Props {
as: string | undefined,
options?: RouterOptions
) => any
readonly events: {
readonly on: (event: string, handler: (...args: any) => any) => any
readonly off: (event: string, handler: (...args: any) => any) => any
}
}
readonly initialClientOnlyAsPath?: string
readonly asPath: string
readonly defaultPushOptions?: RouterOptions
readonly defaultReplaceOptions?: RouterOptions
Expand All @@ -39,6 +36,7 @@ interface Props {
const GeschichteForNextjs: FC<Props> = ({
children,
asPath,
initialClientOnlyAsPath,
Router,
defaultPushOptions,
defaultReplaceOptions
Expand All @@ -47,7 +45,9 @@ const GeschichteForNextjs: FC<Props> = ({
return {
initialSearch: () => {
const [, query] =
typeof window === 'undefined' ? split(asPath) : split(Router.asPath)
typeof window === 'undefined'
? split(asPath)
: split(initialClientOnlyAsPath || Router.asPath)
return `?${query || ''}`
},
push: (next: string, options) => {
Expand All @@ -65,7 +65,12 @@ const GeschichteForNextjs: FC<Props> = ({
})
}
}
}, [defaultPushOptions, defaultReplaceOptions, Router])
}, [
defaultPushOptions,
defaultReplaceOptions,
Router,
initialClientOnlyAsPath
])

const useStore = useMemo(() => useGeschichte(historyInstance), [
historyInstance
Expand Down

0 comments on commit 739a007

Please sign in to comment.