mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-07 08:26:51 +00:00
fix(RooTips): Clear setTimeout in useEffect cleanup to prevent state updates on unmounted components (#4235)
fix: auto patch for RooTips_37
This commit is contained in:
parent
15b37134c1
commit
815a0fb846
1 changed files with 8 additions and 2 deletions
|
|
@ -32,15 +32,21 @@ const RooTips = ({ cycle = false }: RooTipsProps) => {
|
|||
useEffect(() => {
|
||||
if (!cycle) return
|
||||
|
||||
let timeoutId: NodeJS.Timeout | undefined = undefined
|
||||
const intervalId = setInterval(() => {
|
||||
setIsFading(true) // Start fade out
|
||||
setTimeout(() => {
|
||||
timeoutId = setTimeout(() => {
|
||||
setCurrentTipIndex((prevIndex) => (prevIndex + 1) % tips.length)
|
||||
setIsFading(false) // Start fade in
|
||||
}, 1000) // Fade duration
|
||||
}, 11000) // 10s display + 1s fade
|
||||
|
||||
return () => clearInterval(intervalId) // Cleanup on unmount
|
||||
return () => {
|
||||
clearInterval(intervalId)
|
||||
if (timeoutId) {
|
||||
clearTimeout(timeoutId)
|
||||
}
|
||||
}
|
||||
}, [cycle])
|
||||
|
||||
const currentTip = tips[currentTipIndex]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue