Skip to content

connect-react support for hidden reloader prop #16408

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions packages/connect-react/src/hooks/form-context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,24 @@ export const FormContextProvider = <T extends ConfigurableProps>({
enabled: reloadPropIdx != null, // TODO or props.dynamicPropsId && !dynamicProps
});

const triggerHiddenPropsReload = () => {
for (let idx = 0; idx < configurableProps.length; idx++) {
const prop = configurableProps[idx];
if (prop.hidden && prop.reloadProps) {
// Get current value or default
const value = configuredProps[prop.name as keyof ConfiguredProps<T>] ||
("default" in prop && prop.default != null
? prop.default
: undefined);
// Call setConfiguredProp to trigger reload
setConfiguredProp(idx, value);
}
}
};
useEffect(() => {
triggerHiddenPropsReload();
}, []);

const [
propsNeedConfiguring,
setPropsNeedConfiguring,
Expand Down
Loading