Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tannerlinsley committed Oct 17, 2022
1 parent dc7c2ae commit df6f3f9
Show file tree
Hide file tree
Showing 5 changed files with 184 additions and 173 deletions.
2 changes: 1 addition & 1 deletion packages/react-router-devtools/src/Explorer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export const DefaultRenderer: Renderer = ({
}

return (
<Entry key={label}>
<Entry key={label as string}>
{subEntryPages.length ? (
<>
<ExpandButton onClick={() => toggleExpanded()}>
Expand Down
10 changes: 5 additions & 5 deletions packages/react-router-devtools/src/useLocalStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const getItem = (key: string): unknown => {

export default function useLocalStorage<T>(
key: string,
defaultValue: T | undefined
defaultValue: T | undefined,
): [T | undefined, (newVal: T | ((prevVal: T) => T)) => void] {
const [value, setValue] = React.useState<T>()

Expand All @@ -23,16 +23,16 @@ export default function useLocalStorage<T>(

if (typeof initialValue === 'undefined' || initialValue === null) {
setValue(
typeof defaultValue === 'function' ? defaultValue() : defaultValue
typeof defaultValue === 'function' ? defaultValue() : defaultValue,
)
} else {
setValue(initialValue)
}
}, [defaultValue, key])

const setter = React.useCallback(
updater => {
setValue(old => {
(updater: any) => {
setValue((old) => {
let newVal = updater

if (typeof updater == 'function') {
Expand All @@ -45,7 +45,7 @@ export default function useLocalStorage<T>(
return newVal
})
},
[key]
[key],
)

return [value, setter]
Expand Down
3 changes: 3 additions & 0 deletions packages/react-router-devtools/src/useMediaQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export default function useMediaQuery(query: string): boolean | undefined {
if (typeof window !== 'undefined') {
return window.matchMedia && window.matchMedia(query).matches
}
return
})

// Watch for changes
Expand All @@ -30,6 +31,8 @@ export default function useMediaQuery(query: string): boolean | undefined {
matcher.removeListener(onChange)
}
}

return
}, [isMatch, query, setIsMatch])

return isMatch
Expand Down
Loading

0 comments on commit df6f3f9

Please sign in to comment.