Skip to content

Commit d948132

Browse files
committed
fix object structure (eg for sx definition)
1 parent 5df9956 commit d948132

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

packages/ra-core/codemods/replace-Datagrid-DataTable.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ const replaceDatagrid = (root, j) => {
8282

8383
const openingElement = j.jsxOpeningElement(
8484
j.jsxIdentifier('DataTable'),
85-
attributes
85+
attributes,
86+
false
8687
);
8788
const closingElement = j.jsxClosingElement(
8889
j.jsxIdentifier('DataTable')
@@ -116,24 +117,20 @@ const cleanAttributes = (node, j) => {
116117
) {
117118
const expression = attr.value.expression;
118119
if (j.ObjectExpression.check(expression)) {
119-
const properties = expression.properties.map(prop => {
120+
expression.properties.map(prop => {
120121
if (
121122
j.ObjectProperty.check(prop) &&
122123
j.Literal.check(prop.key) &&
123124
typeof prop.key.value === 'string'
124125
) {
125-
const newKey = prop.key.value.replace(
126+
prop.key.value = prop.key.value.replace(
126127
/RaDatagrid-/g,
127128
'RaDataTable-'
128129
);
129-
return j.objectProperty(j.literal(newKey), prop.value);
130130
}
131131
return prop;
132132
});
133-
return j.jsxAttribute(
134-
j.jsxIdentifier('sx'),
135-
j.jsxExpressionContainer(j.objectExpression(properties))
136-
);
133+
return attr;
137134
}
138135
}
139136
return attr;

0 commit comments

Comments
 (0)