Socket
Book a DemoInstallSign in
Socket

@cpro-js/react-ui5-notification

Package Overview
Dependencies
Maintainers
2
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cpro-js/react-ui5-notification

latest
Source
npmnpm
Version
1.0.4
Version published
Maintainers
2
Created
Source

@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
    }
  }

  // ....
}

FAQs

Package last updated on 31 Jan 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts