Two little tweaks post ai search ship (#54265)
This commit is contained in:
@@ -43,7 +43,6 @@ export function useQueryParam(
|
|||||||
|
|
||||||
// If the query param changes in the URL, update the state
|
// If the query param changes in the URL, update the state
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
console.log('updating state')
|
|
||||||
const paramValue = router.query[queryParamKey]
|
const paramValue = router.query[queryParamKey]
|
||||||
|
|
||||||
if (paramValue) {
|
if (paramValue) {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { useState, useEffect } from 'react'
|
import { useState, useEffect } from 'react'
|
||||||
|
import throttle from 'lodash/throttle'
|
||||||
|
|
||||||
export function useInnerWindowWidth() {
|
export function useInnerWindowWidth() {
|
||||||
const hasWindow = typeof window !== 'undefined'
|
const hasWindow = typeof window !== 'undefined'
|
||||||
@@ -14,9 +15,9 @@ export function useInnerWindowWidth() {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (hasWindow) {
|
if (hasWindow) {
|
||||||
const handleResize = function () {
|
const handleResize = throttle(function () {
|
||||||
setWidth(getWidth())
|
setWidth(getWidth())
|
||||||
}
|
}, 100)
|
||||||
|
|
||||||
window.addEventListener('resize', handleResize)
|
window.addEventListener('resize', handleResize)
|
||||||
return () => window.removeEventListener('resize', handleResize)
|
return () => window.removeEventListener('resize', handleResize)
|
||||||
|
|||||||
Reference in New Issue
Block a user