Skip to content

Commit

Permalink
refactor(Table.stories): remove redundant useCallback
Browse files Browse the repository at this point in the history
  • Loading branch information
ArturAbdullin committed Apr 25, 2024
1 parent fc56d15 commit 61c8c54
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions src/components/Table/__stories__/Table.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -205,21 +205,12 @@ const DEFAULT_SETTINGS = columns.map((x) => ({id: x.id, isSelected: true}));
const WithTableSettingsTemplate: StoryFn<TableProps<DataItem>> = (args, context) => {
const [settings, setSettings] = React.useState<TableSettingsData>(DEFAULT_SETTINGS);

const updateSettings = React.useCallback(
async (updatedSettings: TableSettingsData) => setSettings(updatedSettings),
[],
);

if (context.parameters.isFactory) {
return (
<TableWithSettingsFactory
{...args}
settings={settings}
updateSettings={updateSettings}
/>
<TableWithSettingsFactory {...args} settings={settings} updateSettings={setSettings} />
);
} else {
return <TableWithSettings {...args} settings={settings} updateSettings={updateSettings} />;
return <TableWithSettings {...args} settings={settings} updateSettings={setSettings} />;
}
};
export const HOCWithTableSettings = WithTableSettingsTemplate.bind({});
Expand Down Expand Up @@ -254,16 +245,11 @@ HOCWithTableSettingsFactory.parameters = {
const WithTableSettingsWithResetTemplate: StoryFn<TableProps<DataItem>> = (args) => {
const [settings, setSettings] = React.useState<TableSettingsData>(DEFAULT_SETTINGS);

const updateSettings = React.useCallback(
async (updatedSettings: TableSettingsData) => setSettings(updatedSettings),
[],
);

return (
<TableWithSettings
{...args}
settings={settings}
updateSettings={updateSettings}
updateSettings={setSettings}
defaultSettings={DEFAULT_SETTINGS}
showResetButton={!_isEqual(DEFAULT_SETTINGS, settings)}
/>
Expand Down

0 comments on commit 61c8c54

Please sign in to comment.