Fix: bad useState usage
This commit is contained in:
parent
6760c39e29
commit
62269699fc
1 changed files with 3 additions and 6 deletions
|
|
@ -62,20 +62,17 @@ const NotificationCenter = ({
|
||||||
const { data, loading } = useQuery(GET_NOTIFICATIONS, {
|
const { data, loading } = useQuery(GET_NOTIFICATIONS, {
|
||||||
pollInterval: 60000
|
pollInterval: 60000
|
||||||
})
|
})
|
||||||
|
|
||||||
const [xOffset, setXoffset] = useState(300)
|
const [xOffset, setXoffset] = useState(300)
|
||||||
|
|
||||||
const [showingUnread, setShowingUnread] = useState(false)
|
const [showingUnread, setShowingUnread] = useState(false)
|
||||||
|
|
||||||
const classes = useStyles({ buttonCoords, xOffset })
|
const classes = useStyles({ buttonCoords, xOffset })
|
||||||
const machines = R.compose(
|
const machines = R.compose(
|
||||||
R.map(R.prop('name')),
|
R.map(R.prop('name')),
|
||||||
R.indexBy(R.prop('deviceId'))
|
R.indexBy(R.prop('deviceId'))
|
||||||
)(data?.machines ?? [])
|
)(R.path(['machines'])(data) ?? [])
|
||||||
const notifications = R.path(['notifications'])(data) ?? []
|
const notifications = R.path(['notifications'])(data) ?? []
|
||||||
const [hasUnread, setHasUnread] = useState(
|
const [hasUnread, setHasUnread] = useState(hasUnreadProp)
|
||||||
hasUnreadProp || (data?.hasUnreadNotifications ?? false)
|
|
||||||
)
|
|
||||||
const [toggleClearNotification] = useMutation(TOGGLE_CLEAR_NOTIFICATION, {
|
const [toggleClearNotification] = useMutation(TOGGLE_CLEAR_NOTIFICATION, {
|
||||||
onError: () => console.error('Error while clearing notification'),
|
onError: () => console.error('Error while clearing notification'),
|
||||||
refetchQueries: () => ['getNotifications']
|
refetchQueries: () => ['getNotifications']
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue