Skip to content

Commit ad8a0b0

Browse files
authored
refactor(AppController): Remove obsolete StateContext references; Relocate file to component/ (fixes #280). (#281)
1 parent 60175fb commit ad8a0b0

File tree

2 files changed

+14
-23
lines changed

2 files changed

+14
-23
lines changed

src/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import AppController from "./components/AppController";
12
import Layout from "./components/Layout";
2-
import AppController from "./contexts/AppController";
33
import NotificationContextProvider from "./contexts/NotificationContextProvider";
44
import UrlContextProvider from "./contexts/UrlContextProvider";
55

src/contexts/AppController.tsx renamed to src/components/AppController.tsx

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
import React, {
2-
createContext,
32
useContext,
43
useEffect,
54
useRef,
65
} from "react";
76

7+
import {NotificationContext} from "../contexts/NotificationContextProvider";
8+
import {
9+
updateWindowUrlHashParams,
10+
URL_HASH_PARAMS_DEFAULT,
11+
URL_SEARCH_PARAMS_DEFAULT,
12+
UrlContext,
13+
} from "../contexts/UrlContextProvider";
814
import useContextStore from "../stores/contextStore";
915
import useLogFileManagerStore from "../stores/logFileManagerProxyStore";
1016
import useLogFileStore from "../stores/logFileStore";
@@ -22,21 +28,8 @@ import {
2228
isWithinBounds,
2329
} from "../utils/data";
2430
import {clamp} from "../utils/math";
25-
import {NotificationContext} from "./NotificationContextProvider";
26-
import {
27-
updateWindowUrlHashParams,
28-
URL_HASH_PARAMS_DEFAULT,
29-
URL_SEARCH_PARAMS_DEFAULT,
30-
UrlContext,
31-
} from "./UrlContextProvider";
3231

3332

34-
const StateContext = createContext<null>(null);
35-
36-
interface StateContextProviderProps {
37-
children: React.ReactNode;
38-
}
39-
4033
/**
4134
* Updates the log event number in the URL to `logEventNum` if it's within the bounds of
4235
* `logEventNumsOnPage`.
@@ -75,14 +68,18 @@ const updateUrlIfEventOnPage = (
7568
return true;
7669
};
7770

71+
interface AppControllerProps {
72+
children: React.ReactNode;
73+
}
74+
7875
/**
7976
* Manages states for the application.
8077
*
8178
* @param props
8279
* @param props.children
8380
* @return
8481
*/
85-
const AppController = ({children}: StateContextProviderProps) => {
82+
const AppController = ({children}: AppControllerProps) => {
8683
const {postPopUp} = useContext(NotificationContext);
8784
const {filePath, isPrettified, logEventNum} = useContext(UrlContext);
8885

@@ -189,14 +186,8 @@ const AppController = ({children}: StateContextProviderProps) => {
189186
setPostPopUp,
190187
]);
191188

192-
193-
return (
194-
<StateContext.Provider value={null}>
195-
{children}
196-
</StateContext.Provider>
197-
);
189+
return children;
198190
};
199191

200192

201193
export default AppController;
202-
export {StateContext};

0 commit comments

Comments
 (0)