<MakeswiftComponent>
The <MakeswiftComponent>
component takes a MakeswiftComponentSnapshot
(returned from calling getComponentSnapshot) and renders React elements using components registered with the runtime.
This API is a WIP and is subject to change. To use this API, you can use the
following version of the Makeswift runtime: 0.0.0-snapshot-20241113160601
Props
-
The Makeswift snapshot to render.
-
The label of the component used in the Visual Builder.
-
The type of the registered Makeswift component. This should match the
type
property that was used when calling registerComponent.
Example
The following example registers a Makeswift component that allows the user to add content to a container using the Visual Builder.
First, you’ll need a React component. Here, we’re going to use one that has a single children
prop, but you can customize the component and its props as needed.
Next, this component needs to be registered with Makeswift. This example uses the Slot
control for a children
property. Notice this children
property matches the name of the property defined in the MyContainer
component.
Each time you register a component, you’ll need to import it into both your
layout.tsx
file and your makeswift/provider.tsx
file.
Then, you’ll need to retrieve the snapshot of the component from the Makeswift API by calling getComponentSnapshot
with a unique ID and pass that snapshot to the <MakeswiftComponent>
component.
Here, the <MakeswiftComponent>
is being rendered on a page with the route /my-page
.
To see this in the Visual Builder, you’ll need to navigate to /my-page
within the URL bar. This page won’t be autopopulated in the builder, so you’ll need to manually navigate to it.
Was this page helpful?