Skip to content

Commit

Permalink
fix(nextjs): revert implementation as it does not gain us anything
Browse files Browse the repository at this point in the history
  • Loading branch information
BowlingX committed Jun 4, 2020
1 parent 3b3a395 commit a13ebf8
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions src/lib/adapters/Next.js.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ interface Props {
readonly off: (event: string, handler: (...args: any) => any) => any
}
}
readonly initialPath: string
readonly asPath: string
}

const GeschichteForNextjs: FC<Props> = ({ children, initialPath, Router }) => {
const GeschichteForNextjs: FC<Props> = ({ children, asPath, Router }) => {
const historyInstance: HistoryManagement = useMemo(() => {
const initial = split(initialPath)
const initial = split(asPath)
const [, query] = initial
return {
initialSearch: `?${query || ''}`,
Expand Down Expand Up @@ -55,19 +55,17 @@ const GeschichteForNextjs: FC<Props> = ({ children, initialPath, Router }) => {

const { updateFromQuery } = state

useEffect(() => {
const [, query] = split(asPath)
updateFromQuery(`?${query || ''}`)
}, [asPath, updateFromQuery])

useEffect(() => {
const { unregister } = state
const handler = (url: string) => {
const [, query] = split(url)
updateFromQuery(`?${query || ''}`)
}
Router.events.on('routeChangeStart', handler)
return () => {
Router.events.off('routeChangeStart', handler)
unregister()
return unregister()
}
}, [updateFromQuery])

}, [state])
return <StoreContext.Provider value={value}>{children}</StoreContext.Provider>
}

Expand Down

0 comments on commit a13ebf8

Please sign in to comment.