1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-05-03 01:18:43 +02:00

Fix: Move hooks to before we bail if the flag is off. (#9659)

This fixes the a react crash when we render more/fewer hooks than on the
previous render if the flag state changes.
This commit is contained in:
Thomas Heartman 2025-03-31 15:59:09 +02:00 committed by GitHub
parent eae7535bfc
commit 89f63285a0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -49,17 +49,17 @@ export const FeatureOverview = () => {
setLastViewed({ featureId, projectId });
}, [featureId]);
const flagOverviewRedesign = useUiFlag('flagOverviewRedesign');
const { setSplashSeen } = useSplashApi();
const { splash } = useAuthSplash();
const [showTooltip, setShowTooltip] = useState(false);
const [hasClosedTooltip, setHasClosedTooltip] = useState(false);
if (!flagOverviewRedesign) {
return <LegacyFleatureOverview />;
}
const { setSplashSeen } = useSplashApi();
const { splash } = useAuthSplash();
const dragTooltipSplashId = 'strategy-drag-tooltip';
const shouldShowStrategyDragTooltip = !splash?.[dragTooltipSplashId];
const [showTooltip, setShowTooltip] = useState(false);
const [hasClosedTooltip, setHasClosedTooltip] = useState(false);
const toggleShowTooltip = (envIsOpen: boolean) => {
setShowTooltip(
!hasClosedTooltip && shouldShowStrategyDragTooltip && envIsOpen,