@formoe/use-app-messages

1.0.3 • Public • Published

use-app-messages

A hook providing a context wrapper and api to set and manage messages.

A Message is an object containing a text and a type.

Create the context like this:

import { MessageProvider } from "./index"

<MessageProvider>
  <YourComponent />
</MessageProvider>

now in the component tree inside the provider you can:

import { useAppMessages, MESSAGE_TYPES } from "./index"

const { addMessage, acknowledge, messages } = useAppMessages()

and then:

  • add a Message via e.g addMessage({text: "some text", type: MESSAGE_TYPES.info})
  • acknowledge a Message via e.g. acknowledge(0)
  • read all messages

AppMessages

With:

import { AppMessages } from "./index"

<AppMessages />

you can integrate a themed component using the hook to show all app messages.

Readme

Keywords

none

Package Sidebar

Install

npm i @formoe/use-app-messages

Weekly Downloads

1

Version

1.0.3

License

MIT License

Unpacked Size

11.6 kB

Total Files

7

Last publish

Collaborators

  • formoeadmin
  • robertpazurek
  • kuhlenfelder