# useUXPContext

A custom React hook that retrieves the UXPContext, throwing an error if used outside a UXPContextProvider.

## Installation

```tsx
import { useUXPContext } from 'uxp/components';
```

## Signature

```tsx
function useUXPContext(): IContextProvider
```

## Examples

```tsx
import { UXPContext } from './Context';
import { useUXPContext } from './useUXPContext';

const MyComponent = () => {
  const context = useUXPContext();
  return <div>{context.$L('hello')}</div>;
};
```

```tsx
import { UXPContext } from './Context';
import { useUXPContext } from './useUXPContext';

const MyComponent = () => {
  const { $L, direction } = useUXPContext();
  return (
    <div style={{ direction: direction }}>
      <p>{ $L('welcome_message') }</p>
    </div>
  );
};
```

## Related Types

* [IContextProvider](https://help.iviva.com/uxp/v5/additional-resources/types/icontextprovider)
* [IPartialContextProvider](https://help.iviva.com/uxp/v5/additional-resources/types/ipartialcontextprovider)
* [Language](https://help.iviva.com/uxp/v5/additional-resources/types/language)
* [ICustomThemes](https://help.iviva.com/uxp/v5/additional-resources/types/icustomthemes)
* [IThemeProps](https://help.iviva.com/uxp/v5/additional-resources/types/ithemeprops)
* [ThemeType](https://help.iviva.com/uxp/v5/additional-resources/types/themetype)
* [UserDetails](https://help.iviva.com/uxp/v5/additional-resources/types/userdetails)
* [NavigationLink](https://help.iviva.com/uxp/v5/additional-resources/types/navigationlink)
* [Routes](https://help.iviva.com/uxp/v5/additional-resources/types/routes)
* [ConfiguredPage](https://help.iviva.com/uxp/v5/additional-resources/types/configuredpage)
* [ComponentType](https://help.iviva.com/uxp/v5/additional-resources/types/componenttype)
* [IUXPFunctions](https://help.iviva.com/uxp/v5/additional-resources/types/iuxpfunctions)
* [ViewOverride](https://help.iviva.com/uxp/v5/additional-resources/types/viewoverride)
* [Environment](https://help.iviva.com/uxp/v5/additional-resources/types/environment)
* [ExecutionOptions](https://help.iviva.com/uxp/v5/additional-resources/types/executionoptions)
* [CachingOptions](https://help.iviva.com/uxp/v5/additional-resources/types/cachingoptions)
* [IDataFunction](https://help.iviva.com/uxp/v5/additional-resources/types/idatafunction)
* [QueryParams](https://help.iviva.com/uxp/v5/additional-resources/types/queryparams)
* [ExecutionResult](https://help.iviva.com/uxp/v5/additional-resources/types/executionresult)
* [ExecuteMicroserviceConfig](https://help.iviva.com/uxp/v5/additional-resources/types/executemicroserviceconfig)
* [ExecuteConfigBase](https://help.iviva.com/uxp/v5/additional-resources/types/executeconfigbase)
* [LucyQueryResult](https://help.iviva.com/uxp/v5/additional-resources/types/lucyqueryresult)
