Skip to content

Commit 8300088

Browse files
authored
fix(core): add state initial fallback when history array is empty (#65)
1 parent caa33a8 commit 8300088

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

.changeset/modern-moons-arrive.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
'@use-funnel/core': patch
3+
'@use-funnel/browser': patch
4+
'@use-funnel/next': patch
5+
'@use-funnel/react-navigation-native': patch
6+
'@use-funnel/react-router-dom': patch
7+
---
8+
9+
fix(core): add state initial fallback when history array is empty

packages/core/src/useFunnel.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export function createUseFunnel<TRouteOption extends RouteOption>(
5757
id: options.id,
5858
initialState: options.initial,
5959
});
60-
const currentState = router.history[router.currentIndex] as FunnelStateByContextMap<TStepContextMap>;
60+
const currentState = (router.history[router.currentIndex] ?? options.initial) as FunnelStateByContextMap<TStepContextMap>;
6161
const currentStateRef = useUpdatableRef(currentState);
6262

6363
const parseStepContext = useCallback(

0 commit comments

Comments
 (0)