mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
26 lines
560 B
TypeScript
26 lines
560 B
TypeScript
import { useRequest } from 'alova';
|
|
|
|
import { FeaturesContext } from '.';
|
|
import type { FC } from 'react';
|
|
|
|
import type { RequiredChildrenProps } from 'utils';
|
|
import * as FeaturesApi from 'api/features';
|
|
|
|
const FeaturesLoader: FC<RequiredChildrenProps> = (props) => {
|
|
const { data: features } = useRequest(FeaturesApi.readFeatures);
|
|
|
|
if (features) {
|
|
return (
|
|
<FeaturesContext.Provider
|
|
value={{
|
|
features
|
|
}}
|
|
>
|
|
{props.children}
|
|
</FeaturesContext.Provider>
|
|
);
|
|
}
|
|
};
|
|
|
|
export default FeaturesLoader;
|