1.0.3 • Published 23 days ago

@cpro-js/react-ui5-notification v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
23 days ago

@cpro-js/react-ui5-notification

Provides a service to add new success or error messages (NotificationService) and a simple renderer component (NotificationRenderer), which takes care of rendering the appropriate user interfaces.

Success messages are rendered as Toast Messages. They automatically disappear after 3 seconds.

Each error message is rendered as Message Box and must be acknowledged by the user.

Installation

$ yarn add @cpro-js/react-ui5-notification

Usage

First add the NotificationRenderer to your app.

import { NotificationRenderer } from "@cpro-js/react-ui5-notification";

// add the Renderer to your App.tsx, beside the AppRouter
  <AppRouter />
  <NotificationRenderer />
//...

Use the NotificationService to show error or success messages. Inject the service as usual:

import { NotificationService } from "@cpro-js/react-ui5-notification";

export const SomeScreen: FC<{}> = () => {
  const { showSuccess, showError } = useInjection(NotificationService);
  const someEventHandler = () => {
    try {
      //...
      showSuccess("Yippie!")
    }
    catch(error: any) {
      showError("Oh no!", error);                       // must be instance of Error
      showError("Oh no!", "my own error message");      // custom error message
      showError("Oh no!", <div>Some complex jsx</div>); // custom complex error message
    }
  }

  // ....
}
1.0.3

23 days ago

1.0.2

4 months ago

0.2.3

4 months ago

0.2.2

4 months ago

1.0.1

4 months ago

1.0.0

6 months ago

0.2.1

8 months ago

0.2.0

8 months ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago