How to use the mson/lib/compiler.isCompiled function in mson

To help you get started, we’ve selected a few mson examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github redgeoff / mson-react / src / component-utils.js View on Github external
getUIComponent(component) {
    const name = component.getClassName();
    const Component = components[name];
    if (Component !== undefined) {
      return Component;
    } else if (compiler.isCompiled(compiler.getComponent(name))) {
      const Parent = Object.getPrototypeOf(component.constructor);
      return this.getUIComponent(new Parent());
    } else {
      // The React component wasn't found so check the MSON layer to see if we can automatically
      // determine the component from any MSON.
      const ancestorName = compiler.getOldestCompiledAncestor(name);
      const Ancestor = compiler.getComponent(ancestorName);
      return this.getUIComponent(new Ancestor());
    }
  }
}