From 4881d987ba10afa87e261e90b2c6096e592f0c78 Mon Sep 17 00:00:00 2001 From: Mathias Wagner Date: Mon, 20 Feb 2023 01:20:46 +0100 Subject: [PATCH] Created the ViewContext.jsx --- .../src/common/contexts/View/ViewContext.jsx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 client/src/common/contexts/View/ViewContext.jsx diff --git a/client/src/common/contexts/View/ViewContext.jsx b/client/src/common/contexts/View/ViewContext.jsx new file mode 100644 index 00000000..a5a7f5a6 --- /dev/null +++ b/client/src/common/contexts/View/ViewContext.jsx @@ -0,0 +1,18 @@ +import React, {useState, createContext} from "react"; + +export const ViewContext = createContext({}); + +export const ViewProvider = (props) => { + const [view, setView] = useState(parseInt(localStorage.getItem("view")) || 0); + + const updateView = (newView) => { + setView(newView); + localStorage.setItem("view", newView); + } + + return ( + + {props.children} + + ) +} \ No newline at end of file