Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotkeys v2 with hooks #4532

Merged
merged 10 commits into from
Feb 18, 2021
Prev Previous commit
Next Next commit
guard against createContext undefined
  • Loading branch information
adidahiya committed Feb 18, 2021
commit 9c3b4aa917c7c3753910eca78fd13ad8e810a141
7 changes: 3 additions & 4 deletions packages/core/src/context/hotkeys/hotkeysProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,10 @@ type HotkeysAction =
| { type: "CLOSE_DIALOG" | "OPEN_DIALOG" };

const initialHotkeysState: HotkeysContextState = { hotkeys: [], isDialogOpen: false };
const noOpDispatch: Dispatch<HotkeysAction> = () => null;

export const HotkeysContext = createContext<[HotkeysContextState, Dispatch<HotkeysAction>]>([
initialHotkeysState,
() => null,
]);
// we can remove this guard once Blueprint depends on React 16
export const HotkeysContext = createContext?.([initialHotkeysState, noOpDispatch]);

const hotkeysReducer = (state: HotkeysContextState, action: HotkeysAction) => {
switch (action.type) {
Expand Down