useNotifications

A hook containing tools to add, remove, and fetch notifications.

import { useNotifications } from 'useink/notifications'

export const MyNotifications = ({ children }) => {
  const { notifications, addNotification, removeNotification } = useNotifications()

  return (
    <div>
      <button
        onClick={() => {
          addNotification({ message: 'hello from the ink! team 🦑', type: 'None' })
        }}
      >
        Say hello
      </button>

      <ul>
        {notifications.map((n) => (
          <li key={n.id} onClick={() => removeNotification(n.id)}>
            {n.message}
          </li>
        ))}
      </ul>
    </div>
  )
}

Return Type

Last updated

Was this helpful?