Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
handleValueChange = value => {
const form = this.props.component;
let { field } = this.state;
let component = null;
// Is the field changing?
if (!field || value.componentName !== field.getClassName()) {
if (field) {
// Prevent listener leak
field.destroy();
}
if (value.componentName) {
component = compiler.newComponent({
component: value.componentName
});
// Is the component a field?
if (component.isField) {
field = component;
} else {
// e.g. Text component is not a field
field = new ComponentField({ content: component });
}
// Auto validate so that the user can preview how the validation will work
const validate = () => {
field.clearErr();
field.validate();
};
// Register optional core components
compiler.registerComponent('FieldEditorForm', FieldEditorForm);
uiComponents.FieldEditorForm = FieldEditorFormUI;
compiler.registerComponent('FormEditor', FormEditor);
uiComponents.FormEditor = FormEditorUI;
compiler.registerComponent('FormBuilder', FormBuilder);
// Register all the components
for (let name in components) {
let component = components[name];
compiler.registerComponent(component.name, component);
}
// Instantiate the app
const app = compiler.newComponent({
component: 'app.App'
});
export default app;
createComponent() {
const { definition } = this.props;
this.setState({ component: compiler.newComponent(definition) });
}