TypeScript definitions for react-notifications lib
npm install react-notifications-typesThis package provides TypeScript type definitions for the react-notifications library, enhancing the development experience by offering type checking and IntelliSense support in TypeScript projects.
To install the type definitions, you can use npm or yarn. Run one of the following commands:
``bash`
npm install @types/react-notifications
or
`bash`
yarn add @types/react-notifications
After installation, the type definitions can be used by simply importing react-notifications in your TypeScript files. TypeScript will automatically recognize the types based on your project's configuration.
Example:
`typescript
import { NotificationManager } from 'react-notifications';
NotificationManager.info('Info message', 'Title here');
`Type definitions
`typescript
export interface Notification {
title: string;
message: string;
level: 'success' | 'error' | 'warning' | 'info';
position?: 'tc' | 'tr' | 'tl' | 'bc' | 'br' | 'bl' | 'cc';
autoDismiss?: number;
dismissible?: boolean;
action?: NotificationAction;
}
export interface NotificationAction {
label: string;
callback: () => void;
}
export interface NotificationsProps {
notifications: Notification[];
onRequestHide?: (notification: Notification) => void;
}
export interface Notification {
title: string;
message: string;
level: 'success' | 'error' | 'warning' | 'info';
position?: 'tc' | 'tr' | 'tl' | 'bc' | 'br' | 'bl' | 'cc';
autoDismiss?: number;
dismissible?: boolean;
action?: NotificationAction;
}
export interface NotificationAction {
label: string;
callback: () => void;
}
export interface NotificationsProps {
notifications: Notification[];
onRequestHide?: (notification: Notification) => void;
}
export class NotificationContainer extends React.Component
export class NotificationManager {
static create(notification: Notification): void;
static remove(notificationId: number): void;
static info(message: string, title?: string, timeOut?: number, onClick?: () => void, priority?: boolean): void;
static success(message: string, title?: string, timeOut?: number, onClick?: () => void, priority?: boolean): void;
static error(message: string, title?: string, timeOut?: number, onClick?: () => void, priority?: boolean): void;
static warning(message: string, title?: string, timeOut?: number, onClick?: () => void, priority?: boolean): void;
}
`
Contributions are always welcome! If you would like to improve the react-notifications-types definitions, please feel free to fork the repository, make your changes, and submit a pull request.
This project is licensed under the MIT License - see the LICENSE.md file for details.
If you have any issues or feature requests, please open an issue on GitHub.