fix passing of options
This commit is contained in:
parent
450a096ebe
commit
689a6796e0
|
@ -33,11 +33,11 @@ const initialState: State = {
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
children: React.ReactNode
|
children: React.ReactNode
|
||||||
config: Config
|
options: Config['options']
|
||||||
}
|
}
|
||||||
|
|
||||||
export const AppProvider = (props: Props) => {
|
export const AppProvider = (props: Props) => {
|
||||||
const { children, config } = props
|
const { children, options } = props
|
||||||
|
|
||||||
const [state, dispatch] = useReducer(reducer, initialState)
|
const [state, dispatch] = useReducer(reducer, initialState)
|
||||||
|
|
||||||
|
@ -46,13 +46,12 @@ export const AppProvider = (props: Props) => {
|
||||||
state,
|
state,
|
||||||
dispatch,
|
dispatch,
|
||||||
options: {
|
options: {
|
||||||
enableSidebar: true,
|
enableSidebar: options?.enableSidebar ?? true,
|
||||||
enableMembers: true,
|
enableMembers: options?.enableMembers ?? true,
|
||||||
...config.options,
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
[state, config.options]
|
[state, options]
|
||||||
)
|
)
|
||||||
|
|
||||||
return <AppContext.Provider value={value}>{children}</AppContext.Provider>
|
return <AppContext.Provider value={value}>{children}</AppContext.Provider>
|
||||||
|
|
|
@ -65,7 +65,7 @@ export const ProtocolProvider = (props: Props) => {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const loadClient = async () => {
|
const loadClient = async () => {
|
||||||
const client = await createClient({ publicKey: options.publicKey })
|
const client = await createClient(options)
|
||||||
dispatch({ type: 'INIT', client })
|
dispatch({ type: 'INIT', client })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,14 +42,20 @@ const Gate = (props: { children: JSX.Element }) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Community = (props: Props) => {
|
export const Community = (props: Props) => {
|
||||||
const { theme, router: Router = BrowserRouter } = props
|
const {
|
||||||
|
theme,
|
||||||
|
router: Router = BrowserRouter,
|
||||||
|
publicKey,
|
||||||
|
environment,
|
||||||
|
options,
|
||||||
|
} = props
|
||||||
|
|
||||||
useTheme(theme)
|
useTheme(theme)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Router>
|
<Router>
|
||||||
<ProtocolProvider options={{ publicKey: props.publicKey }}>
|
<ProtocolProvider options={{ publicKey, environment }}>
|
||||||
<AppProvider config={props}>
|
<AppProvider options={options}>
|
||||||
<DialogProvider>
|
<DialogProvider>
|
||||||
<GlobalStyle />
|
<GlobalStyle />
|
||||||
<Wrapper>
|
<Wrapper>
|
||||||
|
|
Loading…
Reference in New Issue