{"id":13450547,"url":"https://github.com/intercaetera/react-use-message-bar","last_synced_at":"2025-09-10T07:45:10.556Z","repository":{"id":124225663,"uuid":"229440143","full_name":"intercaetera/react-use-message-bar","owner":"intercaetera","description":"A simple message bar hook for React","archived":false,"fork":false,"pushed_at":"2021-10-11T19:36:26.000Z","size":572,"stargazers_count":10,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-11T21:55:44.033Z","etag":null,"topics":["hacktoberfest","notifications","office-ui-fabric","react"],"latest_commit_sha":null,"homepage":"https://www.intercaetera.com/posts/react-message-bar","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/intercaetera.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-12-21T14:37:17.000Z","updated_at":"2021-10-11T19:34:16.000Z","dependencies_parsed_at":"2024-01-07T11:12:25.427Z","dependency_job_id":"6790b077-d1db-4334-9c99-fca215f54cd4","html_url":"https://github.com/intercaetera/react-use-message-bar","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/intercaetera%2Freact-use-message-bar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/intercaetera%2Freact-use-message-bar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/intercaetera%2Freact-use-message-bar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/intercaetera%2Freact-use-message-bar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/intercaetera","download_url":"https://codeload.github.com/intercaetera/react-use-message-bar/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248487729,"owners_count":21112188,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hacktoberfest","notifications","office-ui-fabric","react"],"created_at":"2024-07-31T07:00:35.902Z","updated_at":"2025-04-11T21:55:52.060Z","avatar_url":"https://github.com/intercaetera.png","language":"JavaScript","funding_links":[],"categories":["Packages"],"sub_categories":[],"readme":"# react-use-message-bar\n\n[![Travis][build-badge]][build]\n[![npm package][npm-badge]][npm]\n[![Coveralls][coveralls-badge]][coveralls]\n\nA simple message bar hook for React. Read more about it in the [blog post](https://intercaetera.com/2020-01-31-the-story-of-react-use-message-bar/).\n\n## Installation\n\n```\nnpm install --save react-use-message-bar\n```\n\n## Usage\n\n```js\nimport { useMessageBar, MessageBarSlotFactory } from 'react-use-message-bar';\n\nconst MessageBarSlot = MessageBarSlotFactory();\n\nconst Demo = () =\u003e {\n\tconst { createNotification, props } = useMessageBar();\n\n\tconst handleClick = () =\u003e createNotification(Date.now());\n\n\treturn (\n\t\t\u003cdiv\u003e\n\t\t\t\u003cMessageBarSlot {...props} /\u003e\n\t\t\t\u003cbutton onClick={handleClick}\u003eCreate Bar\u003c/button\u003e\n\t\t\u003c/div\u003e\n\t);\n};\n```\n\n\n## API\n\n### `useMessageBar`\n\nThis hook returns an object with the following properties:\n\n- `createNotification(content, initialId)` - creates a notification\n  - `content` (string or component) - the content of the notification\n  - `initialId` (any, optional) - a unique id of the notification, if empty `shortid` will be used internally.\n\n- `deleteNotification(id)` - deletes a notification with a given id\n\n- `deleteAllNotifications()` - deletes all notifications\n\n- `props` - an object that should be passed to the `MessageBarSlot` to render the notifications properly.\n\n- `bars` - an array of `{ id, content }` objects that represent the currently displayed bars.\n\n### `MessageBarSlotFactory`\n\nThis is a function that creates a MessageBarSlot component that will render given message bars. It accepts one argument - a `MessageBar` component that will be rendered.\n\nThe `MessageBar` component is injected with two props:\n  - `handleDismiss` - a function that should be called when the user would dismiss the bar, for instance by clicking a \"close\" button.\n  - `children` - the content of the message bar.\n\nThe `DefaultMessageBar` component will be used if the `MessageBar` is not provided - see the source for an example how to build it.\n\n\n[build-badge]: https://travis-ci.org/intercaetera/react-use-message-bar.svg?branch=master\n[build]: https://travis-ci.org/intercaetera/react-use-message-bar\n\n[npm-badge]: https://img.shields.io/npm/v/react-use-message-bar.png?style=flat-square\n[npm]: https://www.npmjs.org/package/react-use-message-bar\n\n[coveralls-badge]: https://coveralls.io/repos/github/intercaetera/react-use-message-bar/badge.svg?branch=master\n[coveralls]: https://coveralls.io/github/intercaetera/react-use-message-bar\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fintercaetera%2Freact-use-message-bar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fintercaetera%2Freact-use-message-bar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fintercaetera%2Freact-use-message-bar/lists"}