Skip to content

Commit

Permalink
refactor(react): remove pending: boolean
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyfromundefined committed Aug 7, 2024
1 parent e3dbaac commit f48909f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 19 deletions.
10 changes: 1 addition & 9 deletions integrations/react/src/stable/useActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { useMemo } from "react";
import type { ActivityComponentType } from "../__internal__/ActivityComponentType";
import { makeActivityId } from "../__internal__/activity";
import { useCoreActions } from "../__internal__/core";
import { useTransition } from "../__internal__/shims";
import type { BaseActivities } from "./BaseActivities";

function parseActionOptions(options?: { animate?: boolean }) {
Expand All @@ -21,11 +20,6 @@ function parseActionOptions(options?: { animate?: boolean }) {
}

export type UseActionsOutputType<T extends BaseActivities> = {
/**
* Is transition pending
*/
pending: boolean;

/**
* Push new activity
*/
Expand Down Expand Up @@ -73,11 +67,9 @@ export function useActions<
T extends BaseActivities,
>(): UseActionsOutputType<T> {
const coreActions = useCoreActions();
const [pending] = useTransition();

return useMemo(
() => ({
pending,
push(activityName, activityParams, options) {
const activityId = makeActivityId();

Expand Down Expand Up @@ -135,6 +127,6 @@ export function useActions<
}
},
}),
[coreActions?.push, coreActions?.replace, coreActions?.pop, pending],
[coreActions?.push, coreActions?.replace, coreActions?.pop],
);
}
11 changes: 1 addition & 10 deletions integrations/react/src/stable/useStepActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ import { useMemo } from "react";
import type { ActivityComponentType } from "../__internal__/ActivityComponentType";
import { makeStepId } from "../__internal__/activity";
import { useCoreActions } from "../__internal__/core";
import { useTransition } from "../__internal__/shims";
import type { BaseActivities } from "./BaseActivities";

export type UseStepActionsOutputType<P> = {
pending: boolean;
stepPush: (params: P, options?: {}) => void;
stepReplace: (params: P, options?: {}) => void;
stepPop: (options?: {}) => void;
Expand All @@ -27,11 +25,9 @@ export type UseStepActions<T extends BaseActivities = {}> = <

export const useStepActions: UseStepActions = () => {
const coreActions = useCoreActions();
const [pending] = useTransition();

return useMemo(
() => ({
pending,
stepPush(params) {
const stepId = makeStepId();

Expand All @@ -52,11 +48,6 @@ export const useStepActions: UseStepActions = () => {
coreActions?.stepPop({});
},
}),
[
coreActions?.stepPush,
coreActions?.stepReplace,
coreActions?.stepPop,
pending,
],
[coreActions?.stepPush, coreActions?.stepReplace, coreActions?.stepPop],
);
};

0 comments on commit f48909f

Please sign in to comment.