Merge pull request #234 from Hexastack/fix/config-type

fix(frontend): config context typing
This commit is contained in:
Yassine 2024-10-18 17:18:56 +01:00 committed by GitHub
commit 57a04da0e9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -6,7 +6,7 @@
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file). * 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
*/ */
import { useState, useEffect, createContext } from "react"; import { createContext, useEffect, useState } from "react";
export const ConfigContext = createContext<IConfig | null>(null); export const ConfigContext = createContext<IConfig | null>(null);
@ -16,13 +16,13 @@ export interface IConfig {
} }
export const ConfigProvider = ({ children }) => { export const ConfigProvider = ({ children }) => {
const [config, setConfig] = useState(null); const [config, setConfig] = useState<IConfig | null>(null);
useEffect(() => { useEffect(() => {
const fetchConfig = async () => { const fetchConfig = async () => {
try { try {
const res = await fetch("/config"); const res = await fetch("/config");
const data = await res.json(); const data = (await res.json()) as IConfig;
setConfig(data); setConfig(data);
} catch (error) { } catch (error) {