Skip to content

Commit c28bca2

Browse files
committed
fix(ui): remove side effects from setCurrentStep updater in onboarding provider
The nextStep callback had markOnboardingSeen() and setIsActive(false) inside the setCurrentStep updater function, which must be pure. Moved completion side effects to a useEffect that reacts to the state transition instead. References: #RI-7942 Made-with: Cursor
1 parent 148479f commit c28bca2

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

redisinsight/ui/src/pages/vector-search/components/create-index-onboarding/CreateIndexOnboardingPopover.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export const CreateIndexOnboardingPopover = ({
103103
</Text>
104104
</S.StepCounter>
105105

106-
<Row gap="s" grow={false}>
106+
<Row gap="m" grow={false}>
107107
{!isFirstStep && (
108108
<SecondaryButton
109109
size="small"

redisinsight/ui/src/pages/vector-search/context/create-index-onboarding/CreateIndexOnboardingProvider.tsx

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useCallback, useMemo, useRef, useState } from 'react'
1+
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
22

33
import BrowserStorageItem from 'uiSrc/constants/storage'
44
import { localStorageService } from 'uiSrc/services'
@@ -38,6 +38,13 @@ export const CreateIndexOnboardingProvider = ({
3838
const isActiveRef = useRef(isActive)
3939
isActiveRef.current = isActive
4040

41+
useEffect(() => {
42+
if (isActive && currentStep === null) {
43+
markOnboardingSeen()
44+
setIsActive(false)
45+
}
46+
}, [isActive, currentStep])
47+
4148
const startOnboarding = useCallback(() => {
4249
if (isActiveRef.current) return
4350
if (isOnboardingSeen()) return
@@ -64,19 +71,11 @@ export const CreateIndexOnboardingProvider = ({
6471
prev as (typeof ONBOARDING_STEPS)[number],
6572
)
6673

67-
if (currentIndex === -1) {
68-
markOnboardingSeen()
69-
setIsActive(false)
70-
return null
71-
}
74+
if (currentIndex === -1) return null
7275

7376
const nextIndex = currentIndex + 1
7477

75-
if (nextIndex >= ONBOARDING_STEPS.length) {
76-
markOnboardingSeen()
77-
setIsActive(false)
78-
return null
79-
}
78+
if (nextIndex >= ONBOARDING_STEPS.length) return null
8079

8180
return ONBOARDING_STEPS[nextIndex]
8281
})

0 commit comments

Comments
 (0)