The useMessages hook is part of the Ollie Shop React library and provides functionality to manage notification messages across the application.
useMessages
hook provides a way to manage application messages (notifications, alerts, etc.) in a React application. It allows you to add, remove, and clear messages throughout your application.
messages: Message[]
- Array of all current message objectsaddMessage: (message: Omit<Message, "id">) => void
- Function to add a new messageremoveMessage: (messageId: string) => void
- Function to remove a message by its IDclearAll: () => void
- Function to clear all messagesmessages
array has the following structure:
Property | Type | Description |
---|---|---|
id | string | A unique identifier for the message (automatically generated) |
type | enum | The type of message success | warning | error |
content | string | The main text content of the message |
title | string | Optional title for the message |
success
and an error
Desktop | Mobile |
---|---|
![]() | ![]() |
Message
objectmessageId
: id
of the message to remove