@selfcommunity/react-core
Version:
React Core Components useful for integrating UI Community components (react-ui).
42 lines (40 loc) • 1.21 kB
TypeScript
import React from 'react';
import { SCLocaleContextType } from '../../../types';
/**
* Creates Global Context
*
:::tip Context can be consumed in one of the following ways:
```jsx
1. <SCLocaleContext.Consumer>{(locale,) => (...)}</SCLocaleContext.Consumer>
```
```jsx
2. const scLocaleContext: SCLocaleContextType = useContext(SCLocaleContext);
```
```jsx
3. const scLocaleContext: SCLocaleContextType = useSCLocale();
````
:::
*/
export declare const SCLocaleContext: React.Context<SCLocaleContextType>;
/**
* #### Description:
* This component makes the `intl` available down the React tree.
* @param children
* @return
* ```jsx
* <SCLocaleContext.Provider value={{locale, messages, selectLocale}}>
* ```
*/
export default function SCLocaleProvider({ children }: {
children: React.ReactNode;
}): JSX.Element;
/**
* Export hoc to inject the base theme to components
* @param Component
*/
export declare const withSCLocale: (Component: any) => (props: any) => JSX.Element;
/**
* Let's only export the `useSCLocale` hook instead of the context.
* We only want to use the hook directly and never the context component.
*/
export declare function useSCLocale(): SCLocaleContextType;