Closed flannanl closed 1 week ago
It seems this bug has something to do with useNestedRows
. If I comment it out, my Datagrid table renders.
Looks like this has to do with the new feature released by https://github.com/carbon-design-system/ibm-products/pull/5735. The error happens if I don't have a getAsyncSubRows
provided. If I start adding a dummy one like getAsyncSubRows: async () => {},
. The table then renders.
Hi @flannanl, can you create a reproduction for this? Or share some of your Datagrid implementation?
@matthewgallo I tried to reproduce it in Stackblitz but was not able to do so... However I am able to simplify my current implementation in IBM Cloud Projects to show the problem in the page.
export const getColumns = (t) => [
{
Header: 'name',
accessor: 'text',
},
];
...
const columns = useMemo(() => getColumns(t), []);
const [rows, setRows] = useState([]);
useEffect(() => {
setTimeout(() => {
setRows([{ link: { name: 'foo' }, text: 'foo' }]);
}, 2000);
}, []);
const datagridState = useDatagrid(
{
columns,
data: rows,
// getAsyncSubRows: async () => {},
},
useNestedRows,
);
return (
<div hidden={!isSelected} className={c()}>
<Datagrid datagridState={{ ...datagridState }} />
</div>
);
This will crash my page. If I uncomment the getAsyncSubRows
, it will render.
I've created a reproduction of this using React 17 https://stackblitz.com/edit/github-gkxha8?file=package.json,src%2Fmain.jsx,src%2FExample%2FExample.jsx
What version of @carbon/ibm-products
has this fix in?
Package
Carbon for IBM Products
Description
When moving up to v2.48.0 from v2.47.0, the Datagrid rendering crashes. I am not sure what causing the crash. I tried to create a simple example but I cannot reproduce with it.
Component(s) impacted
This is the stack trace I collected from console.
Browser
Chrome, Safari, Firefox, Microsoft Edge
@carbon/ibm-products (previously @carbon/ibm-cloud-cognitive) version
v2.48.0
Suggested Severity
Severity 1 = The design is broken in a critical way that blocks users from completing tasks or damages the brand. Affects major functionality, no workaround.
Product/offering
IBM Cloud Projects
CodeSandbox or Stackblitz example
N/A
Steps to reproduce the issue (if applicable)
No response
Release date (if applicable)
No response
Code of Conduct