salla-hook

An invisible marker (rendered with display: none) that names a position in the page where other code can inject elements.

An invisible marker (rendered with display: none) that names a position in the page where other code can inject elements. A theme places it where extensions should be able to add content. On load it registers itself with Salla.hooks under the component name salla-hook, and a caller can then use its mount() method to insert an element immediately before the marker.

Use it

In HTML or JSX, use the tag <salla-hook> with the Attribute names below. In React, the wrapper takes the Property names (camelCase).

import { SallaHook } from '@salla.sa/twilight-components-react/hook';

Example

import { SallaHook } from '@salla.sa/twilight-components-react/hook';

export function Example() {
  return (
    <SallaHook name="product-page-after-price" />
  );
}

Properties

PropertyAttributeDescriptionTypeDefault
namenameThe unique name that identifies this hook position. Use a different name for each position on the page.string

Methods

Call these on the element or a React ref.

mount(element: HTMLElement) => Promise<void>

Inserts the given element into the DOM directly before this salla-hook element. Nothing is returned.

ParameterTypeDescription
elementHTMLElementThe element to insert.

On this page