@openmrs/esm-context

3.1.4 • Public • Published

openmrs-esm-context

What is this?

openmrs-esm-context is an in-browser javascript module that provides React Context that can be shared between modules, as well as the OpenMRS React Root Decorator.

Usage

import openmrsRootDecorator from "@openmrs/esm-context";

// 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-app",
})(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-app"
  • 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.

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

Dependencies (1)

Dev Dependencies (4)

Package Sidebar

Install

npm i @openmrs/esm-context

Weekly Downloads

0

Version

3.1.4

License

MPL-2.0

Unpacked Size

44.2 kB

Total Files

12

Last publish

Collaborators

  • ibacher
  • mogoodrich
  • openmrs-bot
  • rkorytkowski
  • psbrandt
  • djazayeri
  • joeldenning
  • fatmali
  • mksd
  • rrameshbtech
  • brandones
  • jdick
  • bmamlin
  • dkibet
  • florianrappl
  • mdubey
  • dennisforthewin