Refactor explorer config into useKnockoutExplorer hook (#397)

Co-authored-by: Steve Faulkner <stfaul@microsoft.com>
This commit is contained in:
Steve Faulkner
2021-01-25 13:56:15 -06:00
committed by GitHub
parent 3529e80f0d
commit b0b973b21a
12 changed files with 368 additions and 343 deletions

14
src/hooks/useConfig.ts Normal file
View File

@@ -0,0 +1,14 @@
import { useEffect, useState } from "react";
import { ConfigContext, initializeConfiguration } from "../ConfigContext";
// This hook initializes global configuration from a config.json file that is injected at deploy time
// This allows the same main Data Explorer build to be exactly the same in all clouds/platforms,
// but override some of the configuration as nesssary
export function useConfig(): Readonly<ConfigContext> {
const [state, setState] = useState<ConfigContext>();
useEffect(() => {
initializeConfiguration().then((response) => setState(response));
}, []);
return state;
}