Skip to content

Commit 7e0fb30

Browse files
committed
[DOP-31844] Ignore duration for nullable field
1 parent 622c33a commit 7e0fb30

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed
Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
import { ReactElement } from "react";
2-
import { FieldProps, FunctionField } from "react-admin";
2+
import { FieldProps, useFieldValue } from "react-admin";
33

44
import DurationField from "./DurationField";
55

6-
const DurationRaField = (props: FieldProps): ReactElement => {
7-
return (
8-
<FunctionField
9-
render={(record) => (
10-
<DurationField fieldSet={record[props.source]} />
11-
)}
12-
{...props}
13-
/>
14-
);
6+
const DurationRaField = ({
7+
source,
8+
...props
9+
}: FieldProps): ReactElement | null => {
10+
const value = useFieldValue({ source });
11+
if (!value) return null;
12+
return <DurationField fieldSet={value} {...props} />;
1513
};
1614

1715
export default DurationRaField;

0 commit comments

Comments
 (0)