You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
932 B
30 lines
932 B
import { useEffect } from 'react'; |
|
import { ReactElement } from 'react-markdown/lib/react-markdown'; |
|
import { atom, useRecoilState } from 'recoil'; |
|
import { makeEmptyClientConfig, ClientConfig } from '../../models/ClientConfig'; |
|
import ClientConfigService from '../../services/ClientConfigService'; |
|
|
|
export const clientConfigState = atom({ |
|
key: 'clientConfigState', |
|
default: makeEmptyClientConfig(), |
|
}); |
|
|
|
export function ClientConfigStore(): ReactElement { |
|
const [, setClientConfig] = useRecoilState<ClientConfig>(clientConfigState); |
|
|
|
const updateClientConfig = async () => { |
|
try { |
|
const config = await ClientConfigService.getConfig(); |
|
console.log(`ClientConfig: ${JSON.stringify(config)}`); |
|
setClientConfig(config); |
|
} catch (error) { |
|
console.error(`ClientConfigService -> getConfig() ERROR: \n${error}`); |
|
} |
|
}; |
|
|
|
useEffect(() => { |
|
updateClientConfig(); |
|
}, []); |
|
|
|
return null; |
|
}
|
|
|