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
  1. Guides
  2. Components

Replacing Components

For example, if you wanted to use your own CustomLogo component you would do:

import BR from '@blueeast/bluerain-os';

const CustomLogo = props => {
  return (
    <div>/* custom component code */</div>
  )
}
BR.Components.replace('Logo', CustomLogo);

Note that replace will preserve any HoCs originally defined using set. In other words, in the following example:

BR.Components.set('Logo', Logo, withCurrentUser, withRouter);
BR.Components.replace('Logo', CustomLogo);

The CustomLogo component will also be wrapped with withCurrentUser and withRouter.

Once you've replaced the Logo component with your own CustomLogo, BR.Components.get('Logo') will now return CustomLogo. If you want an easy way to keep track of which components have been customized, you could add a custom attribute when calling the component as a reminder for yourself:

import BR from '@blueeast/bluerain-os';
const Logo = BR.Components.get('Logo');

const CustomHeader = props => {
  return (
    <div>
      <Logo custom />
    </div>
  )
}
PreviousExtending ComponentsNextAccessing Raw Components

Last updated 6 years ago