BundleComponent
Hosts a home block that comes from an installed Twilight bundle (a component built outside the theme), rendered in the browser only.
import { BundleComponent, BundleComponentProps } from '@salla.sa/twilight-theme-engine/components/home';In plain words
Some home blocks are not part of the theme at all: they come from a Twilight bundle, a package of ready-made web components the merchant installed. The API names such a block with a component_name and a bundle_id.
BundleComponent places the element for that block on the page, and Salla's bundles script, which the engine loads when it sees one, draws it.
Signature
const BundleComponent: React.MemoExoticComponent<(props: BundleComponentProps) => JSX.Element | null>
interface BundleComponentProps {
data: {
component_name: string;
bundle_id: string;
[key: string]: unknown; // passed to the element as JSON config
};
}Example
import {
DefaultHomeComponents,
registerHomeComponents,
} from '@salla.sa/twilight-theme-engine/components/home';
// The default already maps the API path "bundle-component" to BundleComponent.
// Keep it when you register your own blocks:
registerHomeComponents({
...DefaultHomeComponents,
});
How it behaves
After mount it renders a
salla-custom-componentelement withcomponent-name,bundle-idandconfig(every other field ofdata, as JSON). Before mount, and during the server render, it renders nothing.TwilightBundles, which the engine mounts on every page, notices that element and loads the bundles runtime from Salla's CDN, which defines the element.The renderer's wrapper class for this path is
s-block s-block--bundle-<component_name>.
Gotchas
configincludes whatever else is indata, including thepath,positionandpriorityfieldsHomeComponentRendereradds. A bundle that validates its config strictly sees those extra keys.Without a real bundle installed on the store the element stays empty: there is nothing to try with a made-up
bundle_id, which is why this page has no live demo.