Skip to content

Commit 650a15e

Browse files
committed
Change syntax
1 parent 2141939 commit 650a15e

File tree

3 files changed

+19
-18
lines changed

3 files changed

+19
-18
lines changed

packages/ra-ui-materialui/src/detail/EditGuesser.tsx

+7-6
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ export const EditGuesser = (props: EditProps) => {
4444
const EditViewGuesser = props => {
4545
const resource = useResourceContext(props);
4646
const { record } = useEditContext();
47-
const [inferredChild, setInferredChild] = useState(null);
47+
const [child, setChild] = useState(null);
4848
useEffect(() => {
49-
if (record && !inferredChild) {
49+
if (record && !child) {
5050
const inferredElements = getElementsFromRecords(
5151
[record],
5252
editFieldTypes
@@ -56,16 +56,17 @@ const EditViewGuesser = props => {
5656
null,
5757
inferredElements
5858
);
59-
setInferredChild(inferredChild.getElement());
59+
setChild(inferredChild.getElement());
6060

6161
if (process.env.NODE_ENV === 'production') return;
6262

6363
const representation = inferredChild.getRepresentation();
64+
6465
const components = ['Edit']
6566
.concat(
6667
Array.from(
6768
new Set(
68-
Array.from(representation.matchAll(/<([^\/\s>]+)/g))
69+
Array.from(representation.matchAll(/<([^/\s>]+)/g))
6970
.map(match => match[1])
7071
.filter(component => component !== 'span')
7172
)
@@ -88,9 +89,9 @@ ${representation}
8889
);`
8990
);
9091
}
91-
}, [record, inferredChild, resource]);
92+
}, [record, child, resource]);
9293

93-
return <EditView {...props}>{inferredChild}</EditView>;
94+
return <EditView {...props}>{child}</EditView>;
9495
};
9596

9697
EditViewGuesser.propTypes = EditView.propTypes;

packages/ra-ui-materialui/src/detail/ShowGuesser.tsx

+6-6
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ export const ShowGuesser = ({
2727
const ShowViewGuesser = props => {
2828
const resource = useResourceContext(props);
2929
const { record } = useShowContext();
30-
const [inferredChild, setInferredChild] = useState(null);
30+
const [child, setChild] = useState(null);
3131
useEffect(() => {
32-
if (record && !inferredChild) {
32+
if (record && !child) {
3333
const inferredElements = getElementsFromRecords(
3434
[record],
3535
showFieldTypes
@@ -39,7 +39,7 @@ const ShowViewGuesser = props => {
3939
null,
4040
inferredElements
4141
);
42-
setInferredChild(inferredChild.getElement());
42+
setChild(inferredChild.getElement());
4343

4444
if (process.env.NODE_ENV === 'production') return;
4545

@@ -48,7 +48,7 @@ const ShowViewGuesser = props => {
4848
.concat(
4949
Array.from(
5050
new Set(
51-
Array.from(representation.matchAll(/<([^\/\s>]+)/g))
51+
Array.from(representation.matchAll(/<([^/\s>]+)/g))
5252
.map(match => match[1])
5353
.filter(component => component !== 'span')
5454
)
@@ -71,9 +71,9 @@ ${inferredChild.getRepresentation()}
7171
);`
7272
);
7373
}
74-
}, [record, inferredChild, resource]);
74+
}, [record, child, resource]);
7575

76-
return <ShowView {...props}>{inferredChild}</ShowView>;
76+
return <ShowView {...props}>{child}</ShowView>;
7777
};
7878

7979
ShowViewGuesser.propTypes = ShowView.propTypes;

packages/ra-ui-materialui/src/list/ListGuesser.tsx

+6-6
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,14 @@ export const ListGuesser = <RecordType extends RaRecord = any>(
7171
const ListViewGuesser = (props: Omit<ListViewProps, 'children'>) => {
7272
const { data } = useListContext(props);
7373
const resource = useResourceContext();
74-
const [inferredChild, setInferredChild] = useState(null);
74+
const [child, setChild] = useState(null);
7575

7676
useEffect(() => {
77-
setInferredChild(null);
77+
setChild(null);
7878
}, [resource]);
7979

8080
useEffect(() => {
81-
if (data && data.length > 0 && !inferredChild) {
81+
if (data && data.length > 0 && !child) {
8282
const inferredElements = getElementsFromRecords(
8383
data,
8484
listFieldTypes
@@ -88,7 +88,7 @@ const ListViewGuesser = (props: Omit<ListViewProps, 'children'>) => {
8888
null,
8989
inferredElements
9090
);
91-
setInferredChild(inferredChild.getElement());
91+
setChild(inferredChild.getElement());
9292

9393
if (process.env.NODE_ENV === 'production') return;
9494

@@ -120,9 +120,9 @@ ${inferredChild.getRepresentation()}
120120
);`
121121
);
122122
}
123-
}, [data, inferredChild, resource]);
123+
}, [data, child, resource]);
124124

125-
return <ListView {...props}>{inferredChild}</ListView>;
125+
return <ListView {...props}>{child}</ListView>;
126126
};
127127

128128
ListViewGuesser.propTypes = ListView.propTypes;

0 commit comments

Comments
 (0)