Skip to content

Commit

Permalink
remove HooksDemo
Browse files Browse the repository at this point in the history
  • Loading branch information
puncsky committed Jan 17, 2021
1 parent d02f642 commit 2a88f68
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 81 deletions.
102 changes: 31 additions & 71 deletions src/shared/app.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
import { Switch } from "onefx/lib/react-router";
import { Route } from "onefx/lib/react-router-dom";
import { styled } from "onefx/lib/styletron-react";
import React, { useEffect, useState } from "react";
import React, { useEffect } from "react";
import { FOOTER_ABOVE, Footer } from "@/shared/common/footer";
import { Head } from "@/shared/common/head";
import { NotFound } from "@/shared/common/not-found";
import { ScrollToTop } from "@/shared/common/scroll-top";
import { fonts } from "@/shared/common/styles/style-font";
import { TopBar } from "@/shared/common/top-bar";
import { Home } from "@/shared/home/home";
import {
asyncWithLDProvider,
useLDClient,
} from "launchdarkly-react-client-sdk";
import { FlagsStatusTableController } from "./feature-flags/flags-status-table-controller";
import { FlagDetailsController } from "./flag-details/flag-details-controller";

Expand All @@ -22,76 +18,40 @@ type Props = {
googleTid: string;
};

export function App(props: Props): JSX.Element {
const [LDProvider, setFlagsLoaded] = useState<null | React.FC>(null);
const ldClient = useLDClient();
useEffect(() => {
initGoogleAnalytics({ tid: props.googleTid });
(async () => {
try {
const Provider = await asyncWithLDProvider({
clientSideID: "your-client-side-id",
user: {
key: "aa0ceb",
name: "Grace Hopper",
email: "gracehopper@example.com",
},
options: {
baseUrl: "https://stargately.com",
eventsUrl: "https://stargately.com",
streaming: false,
},
});

await ldClient?.identify({ key: "aa0ceb" });

setFlagsLoaded(() => Provider);
} catch (e) {
console.log("failed to load flags", e);
}
})();
}, []);

if (LDProvider) {
return (
<LDProvider>
<Inner />
</LDProvider>
);
}

return <Inner />;
}

const RootStyle = styled("div", ({ $theme }) => ({
...fonts.body,
backgroundColor: $theme?.colors.black10,
color: $theme?.colors.text01,
textRendering: "optimizeLegibility",
}));

const Inner: React.FC = () => (
<RootStyle>
<Head />
<TopBar />
<div style={FOOTER_ABOVE}>
<ScrollToTop>
<Switch>
<Route exact path="/">
<Home />
</Route>
<Route exact path="/default">
<FlagsStatusTableController />
</Route>
<Route exact path="/default/features/:flagKey">
<FlagDetailsController />
</Route>
<Route path="*">
<NotFound />
</Route>
</Switch>
</ScrollToTop>
</div>
<Footer />
</RootStyle>
);
export const App: React.FC<Props> = (props: Props) => {
useEffect(() => {
initGoogleAnalytics({ tid: props.googleTid });
});
return (
<RootStyle>
<Head />
<TopBar />
<div style={FOOTER_ABOVE}>
<ScrollToTop>
<Switch>
<Route exact path="/">
<Home />
</Route>
<Route exact path="/default">
<FlagsStatusTableController />
</Route>
<Route exact path="/default/features/:flagKey">
<FlagDetailsController />
</Route>
<Route path="*">
<NotFound />
</Route>
</Switch>
</ScrollToTop>
</div>
<Footer />
</RootStyle>
);
};
10 changes: 0 additions & 10 deletions src/shared/home/flags-demo.tsx

This file was deleted.

0 comments on commit 2a88f68

Please sign in to comment.