BlueRain OS
  • Introduction
  • API
    • API Reference
  • Guides
    • Apps
      • Installation
      • Creating an App
      • Configuration
    • Components
      • Registering Components
      • Extending Components
      • Replacing Components
      • Accessing Raw Components
      • Components & HoCs
    • Filters
      • Known Filters
    • Plugins
      • Installation
      • Configuration
      • Creating a Plugin
  • Miscellaneous
    • JSON to React
  • Plugins
    • Apollo
    • Internationalization
    • Material UI
    • React Router
    • Redux
    • Redux Devtools
    • Why Did You Update
Powered by GitBook
On this page
  • App or Plugin
  • Using the set method of ComponentRegistry
  1. Guides
  2. Components

Registering Components

There are many ways to register new components in BlueRain:

App or Plugin

The easiest way to add a new component to BlueRain is to use the 'components' static property of you app or plugin:

import { Plugin } from '@blueeast/bluerain-os';

const Logo = props => {
  return (
    <div>/* component code */</div>
  )
}

export default class FooPlugin extends Plugin {

    static pluginName = 'FooPlugin';

    static components = {
        Logo
    };
}

Note that BlueRain uses 'setOrReplace' method on components registered through the components static property of you app or plugin. This means that if there is an existing component of the same name, it will be replaced.

Using the set method of ComponentRegistry

You can add new Components anywhere in the code by calling the set method of ComponentRegistry:

import { Plugin } from '@blueeast/bluerain-os';

const Logo = props => {
  return (
    <div>/* component code */</div>
  )
}

export default class FooPlugin extends Plugin {

    static pluginName = 'FooPlugin';

    static initialize(config, ctx) {
        ctx.Components.set('Logo', Logo);
    }
}

set method will throw an error if some component is already registered on the given key. To avoid this you can use the setOrReplace method instead.

PreviousComponentsNextExtending Components

Last updated 6 years ago