From 1b5000120463d70f2e3ded39491d0998ccaff184 Mon Sep 17 00:00:00 2001 From: Pavel Prichodko <14926950+prichodko@users.noreply.github.com> Date: Tue, 23 Aug 2022 14:59:55 +0200 Subject: [PATCH] fix passing of options --- packages/status-react/src/contexts/app-context.tsx | 11 +++++------ packages/status-react/src/protocol/provider.tsx | 2 +- packages/status-react/src/routes/index.tsx | 12 +++++++++--- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/packages/status-react/src/contexts/app-context.tsx b/packages/status-react/src/contexts/app-context.tsx index 369f40d4..34f0e55f 100644 --- a/packages/status-react/src/contexts/app-context.tsx +++ b/packages/status-react/src/contexts/app-context.tsx @@ -33,11 +33,11 @@ const initialState: State = { interface Props { children: React.ReactNode - config: Config + options: Config['options'] } export const AppProvider = (props: Props) => { - const { children, config } = props + const { children, options } = props const [state, dispatch] = useReducer(reducer, initialState) @@ -46,13 +46,12 @@ export const AppProvider = (props: Props) => { state, dispatch, options: { - enableSidebar: true, - enableMembers: true, - ...config.options, + enableSidebar: options?.enableSidebar ?? true, + enableMembers: options?.enableMembers ?? true, }, }), // eslint-disable-next-line react-hooks/exhaustive-deps - [state, config.options] + [state, options] ) return {children} diff --git a/packages/status-react/src/protocol/provider.tsx b/packages/status-react/src/protocol/provider.tsx index b32023c9..ff1153f3 100644 --- a/packages/status-react/src/protocol/provider.tsx +++ b/packages/status-react/src/protocol/provider.tsx @@ -65,7 +65,7 @@ export const ProtocolProvider = (props: Props) => { useEffect(() => { const loadClient = async () => { - const client = await createClient({ publicKey: options.publicKey }) + const client = await createClient(options) dispatch({ type: 'INIT', client }) } diff --git a/packages/status-react/src/routes/index.tsx b/packages/status-react/src/routes/index.tsx index 69faa672..34fcb1da 100644 --- a/packages/status-react/src/routes/index.tsx +++ b/packages/status-react/src/routes/index.tsx @@ -42,14 +42,20 @@ const Gate = (props: { children: JSX.Element }) => { } export const Community = (props: Props) => { - const { theme, router: Router = BrowserRouter } = props + const { + theme, + router: Router = BrowserRouter, + publicKey, + environment, + options, + } = props useTheme(theme) return ( - - + +