Skip to content

Commit

Permalink
Fix shallow routing (#2173)
Browse files Browse the repository at this point in the history
(patch)
  • Loading branch information
sakulstra authored Mar 31, 2021
1 parent 04a1575 commit a26fdd8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
13 changes: 13 additions & 0 deletions examples/auth/app/pages/test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import {useRouter} from "next/router"
import React from "react"

export default function Test() {
const {replace} = useRouter()

const handleChange = (event: any) => {
// replace({ query }, undefined, { shallow: true })
replace(`/test?p=${event.target.value}`)
}

return <input onChange={handleChange} />
}
3 changes: 2 additions & 1 deletion packages/core/src/blitz-app-root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export function withBlitzAppRoot(UserAppRoot: React.ComponentType<any>) {
}
}
}
const component = React.useMemo(() => withBlitzInnerWrapper(props.Component), [props.Component])

const noPageFlicker =
props.Component.suppressFirstRenderFlicker ||
Expand All @@ -86,7 +87,7 @@ export function withBlitzAppRoot(UserAppRoot: React.ComponentType<any>) {
return (
<>
{noPageFlicker && <NoPageFlicker />}
<UserAppRoot {...props} Component={withBlitzInnerWrapper(props.Component)} />
<UserAppRoot {...props} Component={component} />
</>
)
}
Expand Down

0 comments on commit a26fdd8

Please sign in to comment.