score:1

Accepted answer
const notificationsLength = props.notifications ? Object.keys(props.notifications).filter(function (id) {
    return props.notifications[id].isDiscussionType == false &&
        props.notifications[id].isRead == false
}).length : 0

return (
    <span className="badge badge-pill badge-primary small ml-2">
        {

            notificationsLength &&
            <span>{notificationsLength} new</span>
        }
    </span>
)

score:1

<span className="badge badge-pill badge-primary small ml-2">
 {
  filteredNotifications.length > 0 &&
  (<span>{filteredNotifications.length} new </span>)
 }
</span>

Related Query

More Query from same tag