Skip to content

Commit 63ec8cf

Browse files
committed
codemod -> replace the rowStyle prop of the Datagrid component by rowSx
1 parent f79eb38 commit 63ec8cf

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,19 @@ const replaceDatagrid = (root, j) => {
8181
// Replace Datagrid with DataTable
8282
datagridComponents.replaceWith(({ node }) => {
8383
// remove the `optimized` attribute if it exists
84-
const attributes = node.openingElement.attributes.filter(
84+
const filtredAttributes = node.openingElement.attributes.filter(
8585
attr =>
8686
!(j.JSXAttribute.check(attr) && attr.name.name === 'optimized')
8787
);
8888

89+
// rename the `rowStyle` attribute to `rowSx` if it exists
90+
const attributes = filtredAttributes.map(attr => {
91+
if (j.JSXAttribute.check(attr) && attr.name.name === 'rowStyle') {
92+
return j.jsxAttribute(j.jsxIdentifier('rowSx'), attr.value);
93+
}
94+
return attr;
95+
});
96+
8997
const openingElement = j.jsxOpeningElement(
9098
j.jsxIdentifier('DataTable'),
9199
attributes,

0 commit comments

Comments
 (0)