Skip to content

Commit

Permalink
fix: using formContext hook outside of forms (#340)
Browse files Browse the repository at this point in the history
- fix dependencyWrapper to no longer use RHF hooks outside of generated form context
  • Loading branch information
daniel-belcher authored Jan 22, 2024
1 parent 4120353 commit 0917852
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/services/ui/src/components/RHF/dependencyWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,22 @@ const checkTriggeringValue = (
});
};

export const DependencyWrapper = ({
export const DependencyWrapper = (
props: PropsWithChildren<DependencyWrapperProps>
) => {
// Check for dependencies which won't exist outside of forms
if (
!props.dependency ||
!props.dependency.conditions ||
!props.dependency.effect
) {
return <>{props.children}</>;
}

return <DependencyWrapperHandler {...props} />;
};

const DependencyWrapperHandler = ({
name,
dependency,
children,
Expand Down

0 comments on commit 0917852

Please sign in to comment.