mirror of
https://github.com/strapi/strapi.git
synced 2025-10-28 00:22:51 +00:00
Add useNotification documentation
Signed-off-by: soupette <cyril@strapi.io>
This commit is contained in:
parent
14d9533516
commit
10353d3d6d
@ -0,0 +1,48 @@
|
|||||||
|
<!--- useNotification.stories.mdx --->
|
||||||
|
|
||||||
|
import { Meta } from '@storybook/addon-docs';
|
||||||
|
|
||||||
|
<Meta title="hooks/useNotification" />
|
||||||
|
|
||||||
|
# useNotification
|
||||||
|
|
||||||
|
This component is used in order to apply RBAC to a view. If the user does not have the permissions to access the view he will be redirect to the homepage:
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```
|
||||||
|
import { useNotification } from '@strapi/helper-plugin';
|
||||||
|
import { Button, Main } from '@strapi/parts';
|
||||||
|
|
||||||
|
const HomePage = () => {
|
||||||
|
const toggleNotification = useNotification();
|
||||||
|
|
||||||
|
const handleClick = () => {
|
||||||
|
toggleNotification({
|
||||||
|
// required
|
||||||
|
type: 'info|success|warning',
|
||||||
|
// required
|
||||||
|
message: { id: 'notification.version.update.message', defaultMessage: 'A new version is available' },
|
||||||
|
// optional
|
||||||
|
link: {
|
||||||
|
url: 'https://github.com/strapi/strapi/releases/tag/v4',
|
||||||
|
label: {
|
||||||
|
id: 'notification.version.update.link',
|
||||||
|
defaultMessage: 'See more'
|
||||||
|
},
|
||||||
|
},
|
||||||
|
// optional: default = false
|
||||||
|
blockTransition: true,
|
||||||
|
// optional
|
||||||
|
onClose: () => localStorage.setItem('STRAPI_UPDATE_NOTIF', true),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Main>
|
||||||
|
<h1>This is the homepage</h1>
|
||||||
|
<Button onClick={handleClick}>Display notification</Button>
|
||||||
|
</Main>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
```
|
||||||
Loading…
x
Reference in New Issue
Block a user