1 В избранное 0 Ответвления 0

OSCHINA-MIRROR/open-hand-choerodon-ui

Присоединиться к Gitlife
Откройте для себя и примите участие в публичных проектах с открытым исходным кодом с участием более 10 миллионов разработчиков. Приватные репозитории также полностью бесплатны :)
Присоединиться бесплатно
Клонировать/Скачать
LayoutContext.tsx 1.2 КБ
Копировать Редактировать Web IDE Исходные данные Просмотреть построчно История
HughHzWu Отправлено 3 лет назад bad5b40
import React, { FunctionComponent, memo, ReactNode, useMemo } from 'react';
import { getContext, Symbols } from 'choerodon-ui/shared';
import { getPrefixCls } from '../configure/utils';
export interface LayoutContextValue {
siderHook?: {
addSider: (id: string) => void,
removeSider: (id: string) => void;
};
getPrefixCls(suffixCls: string, customizePrefixCls?: string): string;
}
export interface LayoutContextProviderProps extends LayoutContextValue {
children?: ReactNode;
}
const LayoutContext = getContext<LayoutContextValue>(Symbols.LayoutContext, { getPrefixCls });
const BaseLayoutContextProvider: FunctionComponent<LayoutContextProviderProps> = function LayoutContextProvider(props) {
const { children, siderHook, getPrefixCls: getGlobalPrefixCls } = props;
const value = useMemo(() => ({
siderHook,
getPrefixCls: getGlobalPrefixCls,
}), [getGlobalPrefixCls, siderHook]);
return (
<LayoutContext.Provider value={value}>
{children}
</LayoutContext.Provider>
);
};
BaseLayoutContextProvider.displayName = 'LayoutContextProvider';
export const LayoutContextProvider = memo(BaseLayoutContextProvider);
export default LayoutContext;

Опубликовать ( 0 )

Вы можете оставить комментарий после Вход в систему

1
https://gitlife.ru/oschina-mirror/open-hand-choerodon-ui.git
git@gitlife.ru:oschina-mirror/open-hand-choerodon-ui.git
oschina-mirror
open-hand-choerodon-ui
open-hand-choerodon-ui
master