Skip to content

Commit

Permalink
only query if visible
Browse files Browse the repository at this point in the history
  • Loading branch information
lache-melvin committed Jan 30, 2025
1 parent 57c0343 commit 10e4d3c
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const patientSearchTester = rankWith(10, uiTypeIs('PatientSearch'));

const UIComponent = (props: ControlProps) => {
const { data, handleChange, label, path } = props;

const [patient, setPatient] = React.useState<SearchInputPatient | null>(null);

const onChangePatient = async (patient: SearchInputPatient) => {
Expand All @@ -27,10 +28,6 @@ const UIComponent = (props: ControlProps) => {
setPatient(patientData);
}, [patientData]);

if (!props.visible) {
return null;
}

return (
<DetailInputWithLabelRow
sx={DefaultFormRowSx}
Expand All @@ -46,4 +43,11 @@ const UIComponent = (props: ControlProps) => {
);
};

export const PatientSearch = withJsonFormsControlProps(UIComponent);
const UIComponentWrapper = (props: ControlProps) => {
if (!props.visible) {
return null;
}
return <UIComponent {...props} />;
};

export const PatientSearch = withJsonFormsControlProps(UIComponentWrapper);

0 comments on commit 10e4d3c

Please sign in to comment.