UNPKG

@selfcommunity/react-core

Version:

React Core Components useful for integrating UI Community components (react-ui).

49 lines (45 loc) 1.4 kB
import React from 'react'; import { SCThemeContextType } from '../../../types'; /** * Creates Global Context * :::tip Context can be consumed in one of the following ways: ```jsx 1. <SCThemeContext.Consumer>{(theme,) => (...)}</SCThemeContext.Consumer> ``` ```jsx 2. const scThemeContext: SCThemeContextType = useContext(SCThemeContext); ``` ```jsx 3. const scThemeContext: SCThemeContextType = useSCTheme(); ```` ::: */ export declare const SCThemeContext: React.Context<SCThemeContextType>; /** * #### Description: * This component makes the `theme` available down the React tree. * It should preferably be used at **the root of your component tree**. * See: https://mui.com/system/styled/ * * @param children * @return * ```jsx * <SCThemeContext.Provider value={{theme, setTheme: setCustomTheme}}> * <ThemeProvider theme={theme}>{children}</ThemeProvider> * </SCThemeContext.Provider> * ``` */ export default function SCThemeProvider({ children }: { children: React.ReactNode; }): JSX.Element; /** * Export hoc to inject the base theme to components * @param Component */ export declare const withSCTheme: (Component: any) => (props: any) => JSX.Element; /** * Let's only export the `useSCTheme` hook instead of the context. * We only want to use the hook directly and never the context component. */ export declare function useSCTheme(): SCThemeContextType;