Skip to content

Commit

Permalink
rename form state into flow state
Browse files Browse the repository at this point in the history
  • Loading branch information
charlotteisambert committed Jan 29, 2024
1 parent 83bdb9a commit 4fc52d7
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions packages/example/src/FlowNavigatorExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ export const FlowNavigatorExample = () => {
);
}

const initialFormState = {
const initialFlowState = {
myValue31: false,
myValue4: hasToPassStep4,
};

type FlowState = typeof initialFormState;
type FlowState = typeof initialFlowState;

const config = {
Step31: (flowState: FlowState) => flowState.myValue31,
Expand All @@ -51,7 +51,7 @@ export const FlowNavigatorExample = () => {
<FlowNavigator.Navigator
screenOptions={{headerShown: false}}
config={config}
initialFormState={initialFormState}>
initialFlowState={initialFlowState}>
<FlowNavigator.Screen name="Step1" component={Step1Page} />
<FlowNavigator.Screen name="Step2" component={Step2Navigator} />
<FlowNavigator.Group>
Expand Down
4 changes: 2 additions & 2 deletions packages/lib/src/navigators/createFlowNavigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function FlowNavigator({
screenListeners,
screenOptions,
config,
initialFormState,
initialFlowState,
...rest
}: FlowNavigatorProps) {
const parentNavigation = useNavigation();
Expand All @@ -46,7 +46,7 @@ function FlowNavigator({
FlowActionHelpers<ParamListBase>,
FlowNavigationOptions,
FlowNavigationEventMap
>(buildFlowRouter(quitFlow, { config, initialFormState }), {
>(buildFlowRouter(quitFlow, { config, initialFlowState }), {
id,
initialRouteName,
children,
Expand Down
10 changes: 5 additions & 5 deletions packages/lib/src/routers/FlowRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ export const buildFlowRouter =
quitFlowHelper: () => void,
{
config,
initialFormState,
}: { config: Config<ParamListBase>; initialFormState: FlowState }
initialFlowState,
}: { config: Config<ParamListBase>; initialFlowState: FlowState }
) =>
(
options: FlowRouterOptions
Expand All @@ -65,7 +65,7 @@ export const buildFlowRouter =

const disabledRouteNames = Object.entries(config)
.filter(([_, isRouteNameEnabledCb]) => {
return !isRouteNameEnabledCb(initialFormState);
return !isRouteNameEnabledCb(initialFlowState);
})
.map(([routeName]) => routeName);

Expand Down Expand Up @@ -130,14 +130,14 @@ export const buildFlowRouter =
return state;

case "SET_STORE_STATE":
const newFormState = {
const newFlowState = {
...state.flowState,
...action.payload.flowState,
};

const disabledRouteNames = Object.entries(config)
.filter(([_, isRouteNameEnabledCb]) => {
return !isRouteNameEnabledCb(newFormState);
return !isRouteNameEnabledCb(newFlowState);
})
.map(([routeName]) => routeName);

Expand Down
2 changes: 1 addition & 1 deletion packages/lib/src/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export type FlowNavigatorProps = DefaultNavigatorOptions<
StackRouterOptions &
NativeStackNavigationConfig & {
config: Config<ParamListBase>;
initialFormState: FlowState;
initialFlowState: FlowState;
};

export type FlowStackNavigationOptions = NativeStackNavigationOptions & {
Expand Down

0 comments on commit 4fc52d7

Please sign in to comment.