Skip to content

Commit b35b310

Browse files
committed
refactor(web): simplify Onboarding component structure and improve readability
1 parent e937d3a commit b35b310

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

packages/web/src/views/Onboarding/components/Onboarding.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useEffect, useRef, useState } from "react";
1+
import React, { useState } from "react";
22
import styled from "styled-components";
33
import { useOnboardingShortcuts } from "../hooks/useOnboardingShortcuts";
44

@@ -158,19 +158,13 @@ export const Onboarding: React.FC<Props> = ({
158158
};
159159

160160
const currentStep = steps[currentStepIndex];
161-
const StepComponent = currentStep?.component;
162-
163-
if (!StepComponent) {
164-
return null;
165-
}
166-
167161
// Get navigation control from step configuration
168162
const preventNavigation = currentStep.preventNavigation || false;
169163
const isNextBtnDisabled = currentStep.nextButtonDisabled || false;
170164
const canNavigateNext = currentStep.canNavigateNext !== false; // Default to true
171165
const handlesKeyboardEvents = currentStep.handlesKeyboardEvents || false;
166+
const StepComponent = currentStep?.component;
172167

173-
// Use the keyboard shortcuts hook
174168
useOnboardingShortcuts({
175169
onNext: handleNext,
176170
onPrevious: handlePrevious,
@@ -180,6 +174,10 @@ export const Onboarding: React.FC<Props> = ({
180174
disablePrevious: currentStep.disablePrevious || false,
181175
});
182176

177+
if (!StepComponent) {
178+
return null;
179+
}
180+
183181
// Handle navigation control changes from steps
184182
const handleNavigationControlChange = (shouldPrevent: boolean) => {
185183
setIsNavPrevented(shouldPrevent);

0 commit comments

Comments
 (0)