Skip to content

Commit

Permalink
refactor(stackflow): Refactoring stackflow (#404)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssi02014 authored Aug 1, 2023
1 parent da0f34b commit ecf46e6
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function googleAnalyticsPlugin<
trackingId,
userInfo,
useTitle = false,
}: GoogleAnalyticsPluginOptions): StackflowReactPlugin<T> {
}: GoogleAnalyticsPluginOptions): StackflowReactPlugin {
return () => ({
key: "@daangn/stackflow-google-analytics-plugin",
onInit() {
Expand Down
2 changes: 1 addition & 1 deletion extensions/plugin-history-sync/src/historySyncPlugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function historySyncPlugin<
T extends { [activityName: string]: unknown },
>(
options: HistorySyncPluginOptions<Extract<keyof T, string>>,
): StackflowReactPlugin<T> {
): StackflowReactPlugin {
type K = Extract<keyof T, string>;

const history =
Expand Down
2 changes: 1 addition & 1 deletion extensions/plugin-preload/src/pluginPreload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export type PreloadPluginOptions<

export function preloadPlugin<T extends { [activityName: string]: unknown }>(
options: PreloadPluginOptions<T>,
): StackflowReactPlugin<T> {
): StackflowReactPlugin {
return () => ({
key: "plugin-preload",
wrapStack({ stack }) {
Expand Down
2 changes: 1 addition & 1 deletion integrations/react/src/StackflowReactPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Activity, Stack, StackflowPlugin } from "@stackflow/core";

export type StackflowReactPlugin<T = never> = () => {
export type StackflowReactPlugin = () => {
/**
* Determine how to render by using the stack state
*/
Expand Down
10 changes: 5 additions & 5 deletions integrations/react/src/stackflow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ function parseActionOptions(options?: { animate?: boolean }) {
return { skipActiveState: false };
}

const isNullableAnimateOption =
options.animate === undefined || options.animate == null;
const isNullableAnimateOption = options.animate == null;

if (isNullableAnimateOption) {
return { skipActiveState: false };
}
Expand All @@ -43,7 +43,7 @@ export type StackComponentType = React.FC<{
}>;

type StackflowPluginsEntry<T extends BaseActivities> =
| StackflowReactPlugin<T>
| StackflowReactPlugin
| StackflowPluginsEntry<T>[];

export type StackflowOptions<T extends BaseActivities> = {
Expand Down Expand Up @@ -120,7 +120,7 @@ export function stackflow<T extends BaseActivities>(
): StackflowOutput<T> {
const plugins = (options.plugins ?? [])
.flat(Infinity as 0)
.map((p) => p as StackflowReactPlugin<T>);
.map((p) => p as StackflowReactPlugin);
const pluginInstances = plugins.map((plugin) => plugin());

const activityComponentMap = Object.entries(options.activities).reduce(
Expand Down Expand Up @@ -285,7 +285,7 @@ export function stackflow<T extends BaseActivities>(

[plugin]
.flat(Infinity as 0)
.map((p) => p as StackflowReactPlugin<T>)
.map((p) => p as StackflowReactPlugin)
.forEach((p) => {
plugins.push(p);
pluginInstances.push(p());
Expand Down
4 changes: 2 additions & 2 deletions integrations/react/src/useActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ function parseActionOptions(options?: { animate?: boolean }) {
return { skipActiveState: false };
}

const isNullableAnimateOption =
options.animate === undefined || options.animate == null;
const isNullableAnimateOption = options.animate == null;

if (isNullableAnimateOption) {
return { skipActiveState: false };
}
Expand Down
2 changes: 1 addition & 1 deletion integrations/react/src/utils/useMemoDeep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export function useMemoDeep<T>(next: T) {
if (!isEqual) {
previousRef.current = next;
}
});
}, [next]);

return isEqual ? previous : next;
}

1 comment on commit ecf46e6

@vercel
Copy link

@vercel vercel bot commented on ecf46e6 Aug 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.