From 938ce130cda6a271cebabed60d54eb691821acb3 Mon Sep 17 00:00:00 2001 From: Jalil Arfaoui Date: Fri, 24 Feb 2023 22:50:53 +0100 Subject: [PATCH] refactor: DisplayModeContext --- src/context/DisplayModeContext.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/context/DisplayModeContext.ts b/src/context/DisplayModeContext.ts index 6a59de7..a7f77dc 100644 --- a/src/context/DisplayModeContext.ts +++ b/src/context/DisplayModeContext.ts @@ -1,10 +1,15 @@ import React from "react"; import { ViewMode } from "../routes/ViewMode"; -export const DisplayModeContext = React.createContext<{ - mode: ViewMode; - setMode: (mode: ViewMode) => void; -}>({ +const defaultValue: DisplayModeContextType = { mode: "map", setMode: () => {}, -}); +}; + +interface DisplayModeContextType { + mode: ViewMode; + setMode: (mode: ViewMode) => void; +} + +export const DisplayModeContext = + React.createContext(defaultValue);