From bbdab8dbf9d3db5f768f06ac69dbd5c778b9a3cf Mon Sep 17 00:00:00 2001 From: Geoff Cox Date: Sat, 28 Aug 2021 12:18:25 -0700 Subject: [PATCH] feat(demo): use register helper (#283) * feat(demo): ui-component render * feat(demo): use register helper --- src/demo/app.js | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/demo/app.js b/src/demo/app.js index 43f7aa47..ca116fe7 100644 --- a/src/demo/app.js +++ b/src/demo/app.js @@ -1,4 +1,5 @@ import compiler from 'mson/lib/compiler'; +import register from 'mson/lib/compiler/register'; import components from './components'; import globals from 'mson/lib/globals'; import uiComponents from '../components'; @@ -23,27 +24,24 @@ import { CustomComponentAttach } from './components/custom-component-attach'; globals.set({ reCAPTCHASiteKey: '6LdIbGMUAAAAAJnipR9t-SnWzCbn0ZX2myXBIauh' }); // Register optional core components -compiler.registerComponent('FieldEditorForm', FieldEditorForm); +register('FieldEditorForm', FieldEditorForm); uiComponents.FieldEditorForm = FieldEditorFormUI; -compiler.registerComponent('FormEditor', FormEditor); +register('FormEditor', FormEditor); uiComponents.FormEditor = FormEditorUI; -compiler.registerComponent('FormBuilder', FormBuilder); +register('FormBuilder', FormBuilder); // You can register custom components with the backend and frontend separately -compiler.registerComponent('CustomComponent', CustomComponent); +register('CustomComponent', CustomComponent); uiComponents.CustomComponent = ReactCustomComponent; -compiler.registerComponent('CustomComponentJS', CustomComponentJS); +register('CustomComponentJS', CustomComponentJS); uiComponents.CustomComponentJS = ReactCustomComponentJS; // You can also register UIComponents that bundle the frontend and backend together -compiler.registerComponent('CustomComponentNoProps', CustomComponentNoProps); -compiler.registerComponent('CustomComponentAttach', CustomComponentAttach); +register('CustomComponentNoProps', CustomComponentNoProps); +register('CustomComponentAttach', CustomComponentAttach); // Register all the components -for (let name in components) { - let component = components[name]; - compiler.registerComponent(component.name, component); -} +Object.keys(components).forEach((name) => register(components[name])); // Instantiate the app const app = compiler.newComponent({