Skip to content

Commit

Permalink
set state based on query param
Browse files Browse the repository at this point in the history
  • Loading branch information
nandereck committed Dec 8, 2022
1 parent 1946600 commit f743804
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,16 @@ export default function createPage(swingsetOptions: SwingsetOptions = {}) {
const searchInputRef = useRef<HTMLInputElement>(null)
const [isFullscreen, setIsFullscreen] = useState(false)
const handleFullscreenBttnClick = () => {
setIsFullscreen(!isFullscreen);
router.replace({
query: { ...router.query, isFullscreen: !isFullscreen }
})
}

useEffect(() => {
if (router.query.isFullscreen === 'true') {
if (router.query.isFullscreen && router.query.isFullscreen === 'true') {
setIsFullscreen(true)
} else {
setIsFullscreen(false)
}
}, [router.query.isFullscreen])

Expand Down

0 comments on commit f743804

Please sign in to comment.