@wasl-flow/react
v1.0.1
Published
React renderer for Wasl Flow
Maintainers
Readme
@wasl-flow/react
React renderer for wasl-flow. It renders content models into React elements.
Install
npm install wasl-flow @wasl-flow/react
# or
pnpm add wasl-flow @wasl-flow/reactQuick Start
import { ReactRenderer } from '@wasl-flow/react';
type ButtonModel = { type: 'button'; text: string; variant?: string };
const renderer = new ReactRenderer({ showValidationErrors: true });
renderer.register({
type: 'button',
parse: model => ({ data: model as ButtonModel }),
factory: ({ model }) => (
<button className={`btn-${model.variant ?? 'primary'}`}>{model.text}</button>
),
});
export function App() {
return <div>{renderer.render({ type: 'button', text: 'Click me' })}</div>;
}Renderer Behavior
renderreturns aReact.ReactNode.renderArrayaggregates multiple outputs into a ReactFragmentand filtersnullandundefined.- Default
nullValueisnullfor React compatibility. - When
showValidationErrorsis enabled, errors are rendered as a styled React element with sanitized details.
Configuration
All RendererConfiguration options from the core package are supported. This renderer only changes the default nullValue to null.
For details on registration, parsing, and safety limits, see the core package README.
