Skip to content

Commit

Permalink
chore: fix Table story
Browse files Browse the repository at this point in the history
  • Loading branch information
veej committed Aug 28, 2024
1 parent 1382b9e commit 02580f6
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useCallback, useState, ComponentProps } from "react";
import { useCallback, useState, ComponentProps, useRef } from "react";
import {
tableColumn,
FormRow,
Expand Down Expand Up @@ -539,7 +539,7 @@ export const WithControlledSorting = {
onSort: action("onSort"),
},
render: (args) => {
const [, setArgs] = useArgs();
const [data, setData] = useState(args.data);

const [numberOfRows, setNumberOfRows] = useState(2);

Expand All @@ -561,9 +561,9 @@ export const WithControlledSorting = {
}),
sortBy.map((a) => (a.desc ? "desc" : "asc"))
).slice(0, numberOfRows);
setArgs({ data: newData });
setData(newData);
},
[numberOfRows, setArgs, args.data]
[numberOfRows]

Check warning on line 566 in packages/bento-design-system/stories/Components/Table.stories.tsx

View workflow job for this annotation

GitHub Actions / Checks (eslint-check)

React Hook useCallback has a missing dependency: 'args.data'. Either include it or remove the dependency array
);

return (
Expand All @@ -574,12 +574,12 @@ export const WithControlledSorting = {
label="Number of rows"
placeholder="Number of rows"
value={numberOfRows}
onChange={setNumberOfRows}
onChange={(n) => setNumberOfRows(n)}
/>
</FormRow>
{/* NOTE(gabro): no idea why TS complains on the onSort type here */}
{/* @ts-expect-error */}
<Table {...args} onSort={onSort} />
<Table {...args} onSort={onSort} data={data} />
</Stack>
);
},
Expand Down

0 comments on commit 02580f6

Please sign in to comment.