fix passing of options

This commit is contained in:
Pavel Prichodko 2022-08-23 14:59:55 +02:00
parent 8850270779
commit 1b50001204
No known key found for this signature in database
GPG Key ID: 8E4C82D464215E83
3 changed files with 15 additions and 10 deletions

View File

@ -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 <AppContext.Provider value={value}>{children}</AppContext.Provider>

View File

@ -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 })
}

View File

@ -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 (
<Router>
<ProtocolProvider options={{ publicKey: props.publicKey }}>
<AppProvider config={props}>
<ProtocolProvider options={{ publicKey, environment }}>
<AppProvider options={options}>
<DialogProvider>
<GlobalStyle />
<Wrapper>