@21kb/react-notification-hook 中文文档教程
@21kb/react-notification-hook
使用通知 API 的 React 挂钩
Install
npm
npm install --save @21kb/react-notification-hook
Yarn
yarn add @21kb/react-notification-hook
Usage
import useNotification from '@21kb/react-notification-hook';
const Component = () => {
const notify = useNotification({
title: 'Test notification!',
options: {
dir: 'rtl',
}
});
return (
<button onClick={notify()}>Notify me!</button>
);
};
注意:useNotification
假定用户已授予权限。
License
麻省理工学院
@21kb/react-notification-hook
React hook to use the Notifications API
Install
npm
npm install --save @21kb/react-notification-hook
Yarn
yarn add @21kb/react-notification-hook
Usage
import useNotification from '@21kb/react-notification-hook';
const Component = () => {
const notify = useNotification({
title: '???? Test notification!',
options: {
dir: 'rtl',
}
});
return (
<button onClick={notify()}>Notify me!</button>
);
};
NOTE: useNotification
assumes the user has already granted permissions.
License
MIT