-
Notifications
You must be signed in to change notification settings - Fork 167
Fix Node 20 lint violations and React hook warnings #1240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -71,8 +71,8 @@ export const workerfyActor = (actor: AnyActorLogic) => { | |||||
| } | ||||||
|
|
||||||
| if (event.data.type === WORKER_COMMANDS.STOP_ACTOR) { | ||||||
| snapshotSubscription?.unsubscribe && snapshotSubscription.unsubscribe(); | ||||||
| actorRef?.stop && actorRef.stop(); | ||||||
| snapshotSubscription?.unsubscribe?.(); | ||||||
| actorRef?.stop?.(); | ||||||
|
||||||
| actorRef?.stop?.(); | |
| actorRef?.stop(); |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,4 +1,4 @@ | ||||||
| import { useEffect, useState } from 'react'; | ||||||
| import { useState } from 'react'; | ||||||
| import { Link, ListItemIcon } from '../../base'; | ||||||
| import { MESHERY_CLOUD_PROD } from '../../constants/constants'; | ||||||
| import { ChallengesIcon } from '../../icons'; | ||||||
|
|
@@ -14,18 +14,16 @@ interface ChallengesSectionProps { | |||||
|
|
||||||
| const ChallengesSection: React.FC<ChallengesSectionProps> = ({ filteredAcademyData }) => { | ||||||
| const theme = useTheme(); | ||||||
| const [openChallenges, setOpenChallenges] = useState(false); | ||||||
| const challenges = | ||||||
| filteredAcademyData?.['challenges'] ?? filteredAcademyData?.['challenge'] ?? []; | ||||||
| const hasChallenges = challenges.length > 0; | ||||||
| const [openChallenges, setOpenChallenges] = useState(hasChallenges); | ||||||
| const [autoUpdate, setAutoUpdate] = useState(true); | ||||||
|
|
||||||
| useEffect(() => { | ||||||
| if (autoUpdate) { | ||||||
| setOpenChallenges((filteredAcademyData?.['challenges'] ?? []).length > 0); | ||||||
| } | ||||||
| }, [filteredAcademyData, autoUpdate]); | ||||||
| const isOpen = autoUpdate ? hasChallenges : openChallenges; | ||||||
|
|
||||||
| const toggleOpenChallenges = () => { | ||||||
| setOpenChallenges((prev) => !prev); | ||||||
| setAutoUpdate(false); | ||||||
| setOpenChallenges(!isOpen); | ||||||
|
||||||
| setOpenChallenges(!isOpen); | |
| setOpenChallenges((prev) => !prev); |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,4 +1,4 @@ | ||||||
| import React, { useEffect, useState } from 'react'; | ||||||
| import React, { useState } from 'react'; | ||||||
| import { Link, ListItemIcon } from '../../base'; | ||||||
| import { MESHERY_CLOUD_PROD } from '../../constants/constants'; | ||||||
| import { LearningIcon } from '../../icons'; | ||||||
|
|
@@ -14,18 +14,14 @@ interface LearningSectionProps { | |||||
|
|
||||||
| const LearningSection: React.FC<LearningSectionProps> = ({ filteredAcademyData }) => { | ||||||
| const theme = useTheme(); | ||||||
| const [openLearning, setOpenLearning] = useState<boolean>(false); | ||||||
| const hasLearning = Boolean((filteredAcademyData?.['learning-path'] ?? []).length > 0); | ||||||
| const [openLearning, setOpenLearning] = useState<boolean>(hasLearning); | ||||||
| const [autoUpdate, setAutoUpdate] = useState<boolean>(true); | ||||||
|
|
||||||
| useEffect(() => { | ||||||
| if (autoUpdate) { | ||||||
| setOpenLearning(Boolean((filteredAcademyData?.['learning-path'] ?? []).length > 0)); | ||||||
| } | ||||||
| }, [filteredAcademyData, autoUpdate]); | ||||||
| const isOpen = autoUpdate ? hasLearning : openLearning; | ||||||
|
|
||||||
| const toggleOpenLearning = (): void => { | ||||||
| setOpenLearning((prev) => !prev); | ||||||
| setAutoUpdate(false); | ||||||
| setOpenLearning(!isOpen); | ||||||
|
||||||
| setOpenLearning(!isOpen); | |
| setOpenLearning((prev) => !prev); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The double optional chaining
?.unsubscribe?.()is unnecessary. TheSubscriptiontype from xstate guarantees thatunsubscribeis a method on the object. SincesnapshotSubscriptioncan benull, only the first optional chaining is needed:snapshotSubscription?.unsubscribe(). The second optional chaining adds no value and suggests the method might not exist, which is not the case.