chore: Turn on set-state-in-effect rule#4435
Merged
mrCherry97 merged 16 commits intokyma-project:mainfrom Dec 23, 2025
Merged
Conversation
33 tasks
mrCherry97
requested changes
Dec 12, 2025
Comment on lines
15
to
21
| useEffect(() => { | ||
| if (!showWizard) { | ||
| //Disabled because useState cannot be converted to useMemo as setState is passed to a child | ||
| //eslint-disable-next-line react-hooks/set-state-in-effect | ||
| setKubeconfig(undefined); | ||
| } | ||
| }, [showWizard]); |
Contributor
There was a problem hiding this comment.
Consider if this useEffect is valid, in my opinion we can remove it, and add to onClose function setting that to undefined. Also we are passing setKubeconfig to AddClusterWizard where we can set it in onComplete and onCancel to undefined instead of the useEffect here.
Comment on lines
78
to
81
| useEffect(() => { | ||
| //eslint-disable-next-line react-hooks/set-state-in-effect | ||
| setToken(resource?.users?.[userIndex]?.user?.token); | ||
| }, [resource, userIndex]); |
Contributor
There was a problem hiding this comment.
I don't see added value on this, please double-check, but in my opinion this just could be removed, but I didn't check kubeconfigID flow.
mrCherry97
approved these changes
Dec 16, 2025
| const detailsOpen = useMemo(() => { | ||
| if (layoutState?.layout) { | ||
| setDetailsOpen(layoutState?.layout !== 'OneColumn'); | ||
| console.log(layoutState?.layout !== 'OneColumn'); |
Contributor
There was a problem hiding this comment.
Suggested change
| console.log(layoutState?.layout !== 'OneColumn'); |
Comment on lines
68
to
76
| useEffect(() => { | ||
| if (chatHistory[0].messages.length > 1) { | ||
| //eslint-disable-next-line react-hooks/set-state-in-effect | ||
| setIsInitialScreen(false); | ||
| return; | ||
| } else { | ||
| setIsInitialScreen(true); | ||
| } | ||
| }, [chatHistory]); |
Contributor
There was a problem hiding this comment.
Couldn't this be like this?
Suggested change
| useEffect(() => { | |
| setIsInitialScreen(chatHistory[0].messages.length <= 1); | |
| }, [chatHistory]); |
mrCherry97
requested changes
Dec 16, 2025
Contributor
mrCherry97
left a comment
There was a problem hiding this comment.
I clicked approve instead of request changes, sorry
akucharska
approved these changes
Dec 22, 2025
mrCherry97
approved these changes
Dec 23, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Changes proposed in this pull request:
Changing state based only on props change was refactored as presented here https://react.dev/learn/you-might-not-need-an-effect#adjusting-some-state-when-a-prop-changes
Related issue(s)
#4396
Definition of done
backlog#4567