@itwin/unified-selection-react
Version:
React components for making use of `@itwin/unified-selection` package in React applications more straightforward
31 lines • 1.33 kB
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
import { createContext, useContext } from "react";
const unifiedSelectionContext = createContext(undefined);
/**
* A React context provider that makes given unified selection context available to all child components. This
* is a requirement for `useUnifiedSelectionContext` to return valid context.
*
* See `README.md` for a usage example.
*
* @public
*/
export function UnifiedSelectionContextProvider(props) {
const { children, ...context } = props;
return _jsx(unifiedSelectionContext.Provider, { value: context, children: children });
}
/**
* A React hook for accessing unified selection context. The context must be provided by `UnifiedSelectionContextProvider`,
* otherwise the hook will return `undefined`.
*
* See `README.md` for a usage example.
*
* @public
*/
export function useUnifiedSelectionContext() {
return useContext(unifiedSelectionContext);
}
//# sourceMappingURL=UnifiedSelectionContext.js.map