Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

A plugin can rewrite a class from core or other plugin.

Config Rewrite

In the plugin, we register rewrite in file etc/config.js.

...

Code Block
languagejs
/**
 *
 * @type {MenuComponent}
 */
const component = ComponentFactory.get(MenuComponent);

Rewrite Implementation

To implement rewrite, we need using javascript function. For example, we implement rewrite for MenuComponent as:

Code Block
languagejs
import React, {Fragment} from "react";

/**
 * Rewrite MenuComponent
 *
 * @param {MenuComponent} MenuComponent
 * @returns {RewriteClass}
 */
export default function(MenuComponent) {
    return class Rewrite extends MenuComponent {
        template() {
            let template = super.template();
            return (
              <Fragment>
                Hello World!
                {template}
              </Fragment>
            )
        }
    }
}

Rewrite Epic

Epic is a Function, not a Class. So rewriting epic has a little difference. For example, we implement rewrite for LocationEpic as:

...