createComponent
Last updated
Was this helpful?
Last updated
Was this helpful?
The createComponent
function is used merge a and a template into a Melody Component. The component function must match the melody-streams
API.
Instead of directly providing both the component function and the template, it is possible to create a component in two steps by first providing the component function and then applying the returned function to a template.
This is particularly useful when you would like to conditionally enable a different UI for a component, for example because you're running an A/B test.
This approach can also be useful when different components share the same behaviour. For example, a Checkbox and a ToggleButton might look very different but their behaviour is almost identical when it comes to state (can be toggled, has a selected state, etc.).