@schema-render/core-react
Version:
Through a set of simple JSON Schema, efficiently build a set of forms.
20 lines (19 loc) • 692 B
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import useRootContext from "../hooks/useRootContext";
import assert from "../utils/assert";
import { matchRenderer } from "../utils/renderer";
import RendererExecutor from "./RendererExecutor";
const RendererDistributor = (props)=>{
const rootCtx = useRootContext();
const { schema } = props;
assert.falsy(schema, 'schema is required in RendererDistributor Props.');
const renderer = matchRenderer(rootCtx.renderers, schema.renderType);
if (!renderer) {
return null;
}
return /*#__PURE__*/ _jsx(RendererExecutor, {
...props,
renderer: renderer
});
};
export default RendererDistributor;