From 8cbf8fdcfdceab8a330bdc82e4260a55c125c37d Mon Sep 17 00:00:00 2001
From: Kristóf Marussy <marussy@mit.bme.hu>
Date: Sun, 22 Aug 2021 19:54:51 +0200
Subject: Covert language-web to TypeScript

---
 language-web/src/main/js/RootStore.tsx | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
 create mode 100644 language-web/src/main/js/RootStore.tsx

(limited to 'language-web/src/main/js/RootStore.tsx')

diff --git a/language-web/src/main/js/RootStore.tsx b/language-web/src/main/js/RootStore.tsx
new file mode 100644
index 00000000..2159f440
--- /dev/null
+++ b/language-web/src/main/js/RootStore.tsx
@@ -0,0 +1,28 @@
+
+import React, { createContext, useContext } from 'react';
+
+import EditorStore from './editor/EditorStore';
+
+export default class RootStore {
+  editorStore;
+
+  constructor() {
+    this.editorStore = new EditorStore();
+  }
+}
+
+const StoreContext = createContext<RootStore | undefined>(undefined);
+
+export const RootStoreProvider: React.FC<{ rootStore: RootStore }> = ({ children, rootStore }) => (
+  <StoreContext.Provider value={rootStore}>
+    {children}
+  </StoreContext.Provider>
+);
+
+export const useRootStore = () => {
+  const rootStore = useContext(StoreContext);
+  if (!rootStore) {
+    throw new Error('useRootStore must be used within RootStoreProvider');
+  }
+  return rootStore;
+};
-- 
cgit v1.2.3-54-g00ecf

