-
Notifications
You must be signed in to change notification settings - Fork 0
/
UseRulesetRegistration.ts
22 lines (20 loc) · 1.03 KB
/
UseRulesetRegistration.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
* @module Core
*/
import { useCallback } from "react";
import { useDisposable } from "@itwin/core-react";
import { Ruleset } from "@itwin/presentation-common";
import { RulesetRegistrationHelper } from "../common/RulesetRegistrationHelper";
/**
* Custom hook which registers supplied Ruleset on mount and removes on unmount.
* @public
* @deprecated in 4.x. It is not compatible with React 18 StrictMode. Use `Presentation.presentation.rulesets().add(ruleset)` directly.
*/
export function useRulesetRegistration(ruleset: Ruleset) {
// eslint-disable-next-line deprecation/deprecation
useDisposable(useCallback(() => new RulesetRegistrationHelper(ruleset), [ruleset]));
}