Props
Name | Description | Type | Default |
---|---|---|---|
data | It is array of objects consists of notification messages to be rendered. Schema : {image, message ,detailPage, receivedTime} | string (URL) |Array | JSON | [] |
notificationCard | Custom react component, either class component or functional component that can be render for every message instead of default one. | React.Component | function | null |
classNamePrefix | Custom CSS styles can be given by providing className prefix and including the respective file. | string | "" |
header | Content for header title ,option and its event. | Object | {title : 'Notifications', option: {text: 'Mark all as read',onClick: ()=>{}} |
fetchData | Function for fetching more data on pagination. | function | null |
icon | Notification icon can be provided as image. | Image | |
viewAllBtn | View all option on bottom of notifications. Schema : {text,onclick} | Object | null |
height | Overwrites the default height of the container. | string | number | null |
width | Overwrites the default width of the container. | string | number | null |
headerBackgroundColor | Background color for the header. | string | null |
cardOption | Whether a default options on every message display or not. | bool | true |
markAsRead | This a function that renders on every card. | function | null |
imagePosition | To decide position of image in card. | string | left |
Data Example
import Notifications from "react-notifications-menu"const App = ( ) =>{const data = {[{image :'https://synergi-dev.s3.ap-southeast-1.amazonaws.com/profile-pictures/6b9.png' ,message : 'Lorem ipsum dolor sit amet.',detailPage : '/events',receivedTime:'12h ago'}]}return <Notifications data={data} />}
Usage
import Notifications from "react-notifications-menu"const App = ( ) =>{const data = {[{image :'https://synergi-dev.s3.ap-southeast-1.amazonaws.com/profile-pictures/6b9.png' ,message : 'Lorem ipsum dolor sit amet.',detailPage : '/events',receivedTime:'12h ago'}]}return<Notificationsdata={data}height='500px'width='300px'classNamePrefix='okrjoy'cardOption={data => console.log(data)}viewAllbtn={{ text: 'see all', linkTo: '/seeAll' }}markAsRead={data => console.log(data)}headerBackgroundColor = 'red'header={{title: 'Notifications',option: { text: 'View All', onClick: () => {} }}}/>}