Skip to content

Commit c19369e

Browse files
committed
fix(connect-react): remove accidental useSuspenseQuery + setState during render (1.0.0-preview.4)
1 parent 10e9dba commit c19369e

File tree

7 files changed

+18
-12
lines changed

7 files changed

+18
-12
lines changed

packages/connect-react/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
<!-- markdownlint-disable MD024 -->
22
# Changelog
33

4+
# [1.0.0-preview.4] - 2024-11-27
5+
6+
- Fix accidental use of useSuspenseQuery
7+
- Fix setState during render due to userId useEffect
8+
49
# [1.0.0-preview.3] - 2024-11-27
510

611
- Previous version broken, lack of build before publish (not sure how preview.1 shipped)

packages/connect-react/examples/nextjs/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/connect-react/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/connect-react",
3-
"version": "1.0.0-preview.3",
3+
"version": "1.0.0-preview.4",
44
"description": "Pipedream Connect library for React",
55
"files": [
66
"dist"

packages/connect-react/src/components/InternalField.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1+
import type { ConfigurableProp } from "@pipedream/sdk";
12
import { FormFieldContext } from "../hooks/form-field-context";
23
import { useFormContext } from "../hooks/form-context";
34
import { Field } from "./Field";
45
import { useApp } from "../hooks/use-app";
5-
import {
6-
AppInfo, ConfigurableProp,
7-
} from "@pipedream/sdk";
86

97
type FieldInternalProps<T extends ConfigurableProp> = {
108
prop: T;

packages/connect-react/src/hooks/form-context.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ export const FormContextProvider = <T extends ConfigurableProps>({
141141
}
142142
configurableProps = _configurableProps as unknown as T; // XXX
143143
}
144-
if (reloadPropIdx) {
144+
if (reloadPropIdx != null) {
145145
configurableProps = configurableProps.slice(0, reloadPropIdx + 1) as unknown as T; // XXX
146146
}
147147

@@ -241,8 +241,12 @@ export const FormContextProvider = <T extends ConfigurableProps>({
241241
]);
242242

243243
// clear all props on user change
244+
const [prevUserId, setPrevUserId] = useState(userId)
244245
useEffect(() => {
245-
updateConfiguredProps({});
246+
if (prevUserId !== userId) {
247+
updateConfiguredProps({});
248+
setPrevUserId(userId)
249+
}
246250
}, [
247251
userId,
248252
]);

packages/connect-react/src/hooks/use-app.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import {
2-
useSuspenseQuery, type UseSuspenseQueryOptions,
2+
useQuery, type UseQueryOptions,
33
} from "@tanstack/react-query";
44
import { useFrontendClient } from "./frontend-client-context";
55
import type { AppRequestResponse } from "@pipedream/sdk";
66

77
/**
88
* Get details about an app
99
*/
10-
export const useApp = (slug: string, opts?:{ useQueryOpts?: Omit<UseSuspenseQueryOptions<AppRequestResponse>, "queryKey" | "queryFn">;}) => {
10+
export const useApp = (slug: string, opts?:{ useQueryOpts?: Omit<UseQueryOptions<AppRequestResponse>, "queryKey" | "queryFn">;}) => {
1111
const client = useFrontendClient();
12-
const query = useSuspenseQuery({
12+
const query = useQuery({
1313
queryKey: [
1414
"app",
1515
slug,

pnpm-lock.yaml

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)