From 62269699fc7aae830783912b8765244a2df3ea95 Mon Sep 17 00:00:00 2001 From: csrapr <26280794+csrapr@users.noreply.github.com> Date: Fri, 19 Feb 2021 18:18:15 +0000 Subject: [PATCH] Fix: bad useState usage --- .../components/NotificationCenter/NotificationCenter.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/new-lamassu-admin/src/components/NotificationCenter/NotificationCenter.js b/new-lamassu-admin/src/components/NotificationCenter/NotificationCenter.js index 38aa41c0..d93c2aee 100644 --- a/new-lamassu-admin/src/components/NotificationCenter/NotificationCenter.js +++ b/new-lamassu-admin/src/components/NotificationCenter/NotificationCenter.js @@ -62,20 +62,17 @@ const NotificationCenter = ({ const { data, loading } = useQuery(GET_NOTIFICATIONS, { pollInterval: 60000 }) - const [xOffset, setXoffset] = useState(300) const [showingUnread, setShowingUnread] = useState(false) - const classes = useStyles({ buttonCoords, xOffset }) const machines = R.compose( R.map(R.prop('name')), R.indexBy(R.prop('deviceId')) - )(data?.machines ?? []) + )(R.path(['machines'])(data) ?? []) const notifications = R.path(['notifications'])(data) ?? [] - const [hasUnread, setHasUnread] = useState( - hasUnreadProp || (data?.hasUnreadNotifications ?? false) - ) + const [hasUnread, setHasUnread] = useState(hasUnreadProp) + const [toggleClearNotification] = useMutation(TOGGLE_CLEAR_NOTIFICATION, { onError: () => console.error('Error while clearing notification'), refetchQueries: () => ['getNotifications']