Skip to content

Commit 3d0e5ed

Browse files
authored
Fix dynamic props in the Connect demo app (#14887)
* Switch from snake to camel case to match API response * Upgrade SDK * Fix linter issues * Bump preview version * Update PNPM lock file
1 parent 8cdf895 commit 3d0e5ed

File tree

3 files changed

+30
-26
lines changed

3 files changed

+30
-26
lines changed

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.7",
3+
"version": "1.0.0-preview.8",
44
"description": "Pipedream Connect library for React",
55
"files": [
66
"dist"

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

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ import type {
99
import { useFrontendClient } from "./frontend-client-context";
1010
import type { ComponentFormProps } from "../components/ComponentForm";
1111

12-
export type DynamicProps<T extends ConfigurableProps> = { id: string; configurable_props: T; }; // TODO
12+
export type DynamicProps<T extends ConfigurableProps> = { id: string; configurableProps: T; }; // TODO
1313

1414
export type FormContext<T extends ConfigurableProps> = {
1515
component: V1Component<T>;
16-
configurableProps: T; // dynamicProps.configurable_props || props.component.configurable_props
16+
configurableProps: T; // dynamicProps.configurableProps || props.component.configurable_props
1717
configuredProps: ConfiguredProps<T>;
1818
dynamicProps?: DynamicProps<T>; // lots of calls require dynamicProps?.id, so need to expose
1919
dynamicPropsQueryIsFetching?: boolean;
@@ -117,11 +117,11 @@ export const FormContextProvider = <T extends ConfigurableProps>({
117117
"dynamicProps",
118118
],
119119
queryFn: async () => {
120-
const { dynamic_props } = await client.componentReloadProps(componentReloadPropsInput);
120+
const { dynamicProps } = await client.componentReloadProps(componentReloadPropsInput);
121121
// XXX what about if null?
122122
// TODO observation errors, etc.
123-
if (dynamic_props) {
124-
setDynamicProps(dynamic_props);
123+
if (dynamicProps) {
124+
setDynamicProps(dynamicProps);
125125
}
126126
setReloadPropIdx(undefined);
127127
return []; // XXX ok to mutate above and not look at data?
@@ -130,7 +130,7 @@ export const FormContextProvider = <T extends ConfigurableProps>({
130130
});
131131

132132
// XXX fix types of dynamicProps, props.component so this type decl not needed
133-
let configurableProps: T = dynamicProps?.configurable_props || formProps.component.configurable_props || [];
133+
let configurableProps: T = dynamicProps?.configurableProps || formProps.component.configurable_props || [];
134134
if (propNames?.length) {
135135
const _configurableProps = [];
136136
for (const prop of configurableProps) {
@@ -169,7 +169,7 @@ export const FormContextProvider = <T extends ConfigurableProps>({
169169
errs.push("not a boolean");
170170
}
171171
} else if (prop.type === "string") {
172-
if (typeof value !== "string" ) {
172+
if (typeof value !== "string") {
173173
errs.push("not a string");
174174
}
175175
} else if (prop.type === "app") {
@@ -179,7 +179,7 @@ export const FormContextProvider = <T extends ConfigurableProps>({
179179
};
180180

181181
const updateConfiguredPropsQueryDisabledIdx = (configuredProps: ConfiguredProps<T>) => {
182-
let _queryDisabledIdx = undefined;
182+
let _queryDisabledIdx = undefined;
183183
for (let idx = 0; idx < configurableProps.length; idx++) {
184184
const prop = configurableProps[idx];
185185
if (prop.hidden || (prop.optional && !optionalPropIsEnabled(prop))) {
@@ -241,7 +241,10 @@ export const FormContextProvider = <T extends ConfigurableProps>({
241241
]);
242242

243243
// clear all props on user change
244-
const [prevUserId, setPrevUserId] = useState(userId)
244+
const [
245+
prevUserId,
246+
setPrevUserId,
247+
] = useState(userId)
245248
useEffect(() => {
246249
if (prevUserId !== userId) {
247250
updateConfiguredProps({});

pnpm-lock.yaml

Lines changed: 17 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)