diff --git a/src/lib/hotkeys/index.native.tsx b/src/lib/hotkeys/index.native.tsx index b5562c9c62..a0fe0e105a 100644 --- a/src/lib/hotkeys/index.native.tsx +++ b/src/lib/hotkeys/index.native.tsx @@ -1,10 +1,17 @@ +import {useMemo} from 'react' + export function Provider({children}: {children: React.ReactNode}) { return children } +const noop = () => {} + export function useHotkeysContext() { - return { - enableScope: () => {}, - disableScope: () => {}, - } + return useMemo( + () => ({ + enableScope: noop, + disableScope: noop, + }), + [], + ) } diff --git a/src/state/shell/drawer-open.tsx b/src/state/shell/drawer-open.tsx index fecf93f003..8ddb43469f 100644 --- a/src/state/shell/drawer-open.tsx +++ b/src/state/shell/drawer-open.tsx @@ -1,4 +1,4 @@ -import {createContext, useContext, useState} from 'react' +import {createContext, useCallback, useContext, useState} from 'react' import {useHotkeysContext} from '#/lib/hotkeys' @@ -14,14 +14,17 @@ export function Provider({children}: React.PropsWithChildren<{}>) { const [state, setState] = useState(false) const {disableScope, enableScope} = useHotkeysContext() - const setDrawerOpen = (open: boolean) => { - if (open) { - disableScope('global') - } else { - enableScope('global') - } - setState(open) - } + const setDrawerOpen = useCallback( + (open: boolean) => { + if (open) { + disableScope('global') + } else { + enableScope('global') + } + setState(open) + }, + [disableScope, enableScope], + ) return (