diff --git a/client/state/reactContext.tsx b/client/state/reactContext.tsx
index b41cc94..2c7f774 100644
--- a/client/state/reactContext.tsx
+++ b/client/state/reactContext.tsx
@@ -33,20 +33,16 @@ export function ConsumeState({ children }: ConsumeStateProps) {
export function injectState
(
Component: React.ComponentType
-): React.ComponentClass> {
- return class extends React.Component> {
- render() {
- const consumeState = (state: AppState | null) => {
- if (state == null) {
- throw new Error(
- "Component with injectState must be mounted inside ProvideState"
- );
- }
- // tslint:disable-next-line:no-object-literal-type-assertion
- const allProps: Readonly = {...this.props, appState: state} as Readonly
;
- return ;
- };
- return {consumeState};
+): React.FunctionComponent> {
+ return function InjectState(props) {
+ const state = React.useContext(StateContext);
+ if (state == null) {
+ throw new Error(
+ "Component with injectState must be mounted inside ProvideState"
+ );
}
- };
+ // tslint:disable-next-line: no-object-literal-type-assertion
+ const allProps: Readonly = {...props, appState: state} as Readonly
;
+ return ;
+ }
}