Application code for creating a React pointcut.
Methods
(static) withTogglePoint(controlModule, featuresMap) → {external:React.Component}
A React Higher-Order-Component that wraps a base / control component and swaps in a variant when deemed appropriate by a context
Parameters:
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
controlModule |
ReactComponentModuleNamespaceObject | The control / base module
Properties
|
||||||
featuresMap |
Map | A map of features and their variants, with features as top-level keys and variants as nested keys with modules as the values. |
Returns:
Wrapped react component
(static) withToggledHook(controlModule, featuresMap) → {external:React.Hook}
A React hook that wraps a base / control function or hook and swaps in a variant when deemed appropriate by a context
Parameters:
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
controlModule |
ReactHookModuleNamespaceObject | The control / base module
Properties
|
||||||
featuresMap |
Map | A map of features and their variants, with features as top-level keys and variants as nested keys with modules as the values. |
Returns:
Wrapped function / hook, as a hook (so must be applied in accordance with the rules of hooks)
- Type
- external:React.Hook
(inner) withTogglePointFactory(params) → {module:web-toggle-point-react-pointcuts.withTogglePoint}
A factory function used to create a withTogglePoint React Higher-Order-Component.
Parameters:
Name | Type | Description | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
params |
object | parameters
Properties
|
Returns:
withTogglePoint React Higher-Order-Component.
Example
const withTogglePoint = withTogglePointFactory({
getActiveFeatures,
plugins: [plugin1, plugin2, plugin3],
logError: (error) => window.NREUM?.noticeError(error)
});
export default withTogglePoint(MyReactComponent);
(inner) withToggledHookFactory(params) → {module:web-toggle-point-react-pointcuts.withToggledHook}
A factory function used to create a withToggledHook React hook, wrapping an existing hook/function.
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
params |
object | parameters
Properties
|
Returns:
withToggledHook hook function, use to wrap a function (either a hook itself, or a function that must be called wherever a hook can...).
Example
const getActiveFeatures = () => useContext(myContext);
const withToggledHook = withToggledHookFactory({
getActiveFeatures,
plugins: [plugin1, plugin2, plugin3]
});
export default withToggledHook(useMyHook);
Type Definitions
plugin
A plugin for the point cuts package
Type:
- object
Properties:
Name | Type | Description |
---|---|---|
name |
string | plugin name, used as a prefix when creating React Higher-Order-Components when toggling |
onCodeSelected |
function | hook to be called when a code selection is made |