Skip to content

Commit

Permalink
fix: renamed props according to functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
BowlingX committed Mar 15, 2023
1 parent d6a34ac commit b89eb6b
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/lib/adapters/nextjs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ interface Props {
// tslint:disable-next-line:no-mixed-interface
readonly routerAsPath?: () => string
readonly routerQuery?: () => ParsedUrlQuery
readonly clientSideQuery: () => string
readonly clientSideHref: () => string
readonly clientSideSearch: () => string
readonly routerPush?: (
url: Url,
Expand All @@ -57,7 +57,7 @@ interface Props {
// FIXME: Somehow imports are messed up for nextjs when importing from modules (see https://github.com/vercel/next.js/issues/36794)
const Router = (NextRouter as any as { readonly default: Router$ }).default

const defaultClientSideQuery = () => window.location.href
const defaultClientSideHref = () => window.location.href
const defaultClientSideSearch = () => window.location.search

const queryFromPath = (path: string) => {
Expand All @@ -75,7 +75,7 @@ export const GeschichteForNextjs: FC<Props> = ({
routerQuery,
routerPush,
routerReplace,
clientSideQuery,
clientSideHref,
clientSideSearch,
}) => {
const lastClientSideQuery = useRef(initialClientOnlyAsPath)
Expand Down Expand Up @@ -155,7 +155,7 @@ export const GeschichteForNextjs: FC<Props> = ({

useEffect(() => {
// tslint:disable-next-line
lastClientSideQuery.current = clientSideQuery()
lastClientSideQuery.current = clientSideHref()
updateFromQuery(clientSideSearch())
// tslint:disable-next-line:no-let
let skipEvent = true
Expand All @@ -173,7 +173,7 @@ export const GeschichteForNextjs: FC<Props> = ({
return () => {
Router.events.off('beforeHistoryChange', routeChangeStartHandler)
}
}, [updateFromQuery, clientSideQuery, clientSideSearch])
}, [updateFromQuery, clientSideHref, clientSideSearch])

useEffect(() => {
const { unregister } = state
Expand All @@ -197,7 +197,7 @@ type ClientOnlyProps = Pick<
> & {
readonly children: ReactNode
readonly omitQueries?: boolean
} & Partial<Pick<Props, 'clientSideQuery' | 'clientSideSearch'>>
} & Partial<Pick<Props, 'clientSideHref' | 'clientSideSearch'>>

// see https://nextjs.org/docs/api-reference/next/router#routerpush for options;
// in general we want shallow (see https://nextjs.org/docs/routing/shallow-routing) routing in most cases and not scroll
Expand All @@ -208,7 +208,7 @@ export const GeschichteForNextjsWrapper: FC<ClientOnlyProps> = ({
defaultPushOptions = defaultRoutingOptions,
defaultReplaceOptions = defaultRoutingOptions,
clientSideSearch = defaultClientSideSearch,
clientSideQuery = defaultClientSideQuery,
clientSideHref = defaultClientSideHref,
...props
}) => {
const { asPath } = useRouter()
Expand All @@ -235,7 +235,7 @@ export const GeschichteForNextjsWrapper: FC<ClientOnlyProps> = ({
initialClientOnlyAsPath={thisAsPath}
defaultReplaceOptions={defaultReplaceOptions}
defaultPushOptions={defaultPushOptions}
clientSideQuery={clientSideQuery}
clientSideHref={clientSideHref}
clientSideSearch={clientSideSearch}
asPath={pp}
{...props}
Expand Down

0 comments on commit b89eb6b

Please sign in to comment.