Skip to content
A React error boundary for OpenMRS
JavaScript TypeScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
__mocks__ Providing react-i18next context. (#6) Nov 14, 2019
src
.babelrc Initial implementation (#1) Aug 25, 2019
.eslintrc Initial implementation (#1) Aug 25, 2019
.gitignore Initial implementation (#1) Aug 25, 2019
.travis.yml Fixing tests (#4) Oct 28, 2019
LICENSE Initial commit Aug 25, 2019
README.md Update README.md Nov 21, 2019
jest.config.js Providing react-i18next context. (#6) Nov 14, 2019
package-lock.json 3.1.0 Nov 21, 2019
package.json 3.1.0 Nov 21, 2019

README.md

openmrs-react-root-decorator

Build Status

A decorator for root react components.

Installation

npm install --save @openmrs/react-root-decorator

Usage

import openmrsRootDecorator from "@openmrs/react-root-decorator";

// Exported only for testing the component without the decorator being there.
// You should use the default export for everything but tests.
export function MyRoot(props) {
  return <div>My component</div>;
}

export default openmrsRootDecorator({
  // The featureName is shown to users! Make it human-friendly.
  featureName: "A user-facing thing",
  // moduleName is the name of your in-browser module, as it appears in the import map
  moduleName: "@openmrs/esm-login",
})(MyRoot);

API

@openmrs/react-root-decorator exports a function as the default export. That function must be called with an opts object with the following properties:

  • featureName (required): A string describing the feature. Example is patient search. This string is shown to users.
  • moduleName (required): The string name of your in-browser module, as it appears in the import map. Example: "@openmrs/esm-login"
  • strictMode (optional): A boolean that turns on React strict mode. Defaults to true.
  • throwErrorsToConsole (optional): A boolean that indicates whether React errors should be thrown to the window via setTimeout(() => {throw err}). This is so that an automatic error logging library will be able to pick up the errors. Defaults to true.
  • disableTranslations (optional): A boolean that indicates whether to disable translations with i18next. Defaults to false.

The decorator returns a function that should then be called with your root react component.

You can’t perform that action at this time.