Skip to content

Commit

Permalink
feat(demo): use register helper (#283)
Browse files Browse the repository at this point in the history
* feat(demo): ui-component render

* feat(demo): use register helper
  • Loading branch information
redgeoff authored Aug 28, 2021
1 parent 8607c02 commit bbdab8d
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/demo/app.js
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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({
Expand Down

0 comments on commit bbdab8d

Please sign in to comment.