Skip to content

Instantly share code, notes, and snippets.

@agnanachandran
Created February 15, 2018 21:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agnanachandran/0f27ed52b4d5112cdc0a128d4eafb2df to your computer and use it in GitHub Desktop.
Save agnanachandran/0f27ed52b4d5112cdc0a128d4eafb2df to your computer and use it in GitHub Desktop.
views/notifications_view.tsx
interface NotificationsViewProps {
unreadNotifications: Notification[];
readNotifications: Notification[];
onMarkAsRead: (notification: Notification) => void;
}
class NotificationsView extends React.Component<NotificationsViewProps, {}> {
render(): JSX.Element {
return (
<div>
<h1>Unread Notifications</h1>
{ this.props.unreadNotifications && (
<div>
{ this.props.unreadNotifications.map((notification) => (
<div key={ notification.id }>
{ notification.content }
<span onClick={ () => this.props.onMarkAsRead(notification) }>
Mark as Read
</span>
</div>
)) }
</div>
) }
<h1>Read Notifications</h1>
{ this.props.readNotifications && (
<div>
{ this.props.readNotifications.map((notification) => (
<div key={ notification.id }>
{ notification.content }
</div>
)) }
</div>
) }
</div>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment