Skip to content

Fix missing callback dependencies #2188

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 21, 2024
Merged

Fix missing callback dependencies #2188

merged 3 commits into from
Mar 21, 2024

Conversation

jordankoschei-okta
Copy link
Contributor

Fixes a few missing dependencies in useCallback and useMemo, and replaces .push() with .concat() as per Kevin's suggestion.

@jordankoschei-okta jordankoschei-okta requested a review from a team as a code owner March 20, 2024 18:29
@@ -478,15 +478,15 @@ const DataTable = ({

const convertColumnToFilter = useCallback(
(column: DataTableColumn<DataTableRowData>) =>
column.enableColumnFilter && column.accessorKey
column.enableColumnFilter !== false && column.accessorKey
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is enableColumnFilter a boolean? Not sure we'd need to be this specific here. Unless there is some context I am missing

Copy link
Contributor

@KevinGhadyani-Okta KevinGhadyani-Okta Mar 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is part of material-react-table (right?), or I'd make a comment about is or has prefixes.

I also agree with @bryancunningham-okta. Why not this instead?

Suggested change
column.enableColumnFilter !== false && column.accessorKey
!column.enableColumnFilter && column.accessorKey

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is coming from Material-React-Table. In a column definition, if you set enableColumnFilter to false, a filter won't display for that column.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess what I'm getting at is, enableColumnFilter is either truthy or falsey right? Can just be this

column.enableColumnFilter && column.accessorKey

Comment on lines +507 to +523
return accumulator.concat(filter);
}
}
} else if ("accessorKey" in item) {
// Checks if it's a column
const filter = convertColumnToFilter(item);
if (filter) {
accumulator.push();
return accumulator.concat(filter);
}
} else if ("label" in item) {
// Checks if it's a DataFilter
accumulator.push(item);
return accumulator.concat(item);
}
// If none of the conditions match, item is ignored (not mapping to undefined)
return accumulator;
}, []);
}, [columns, filtersProp]);
}, [columns, filtersProp, convertColumnToFilter]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@jordankoschei-okta jordankoschei-okta merged commit 352bf3b into main Mar 21, 2024
@jordankoschei-okta jordankoschei-okta deleted the jk/OKTA-710606 branch March 21, 2024 18:18
bryancunningham-okta pushed a commit that referenced this pull request Mar 25, 2024
* refactor: replace push with concat

* refactor: fix missing dependencies

* fix: fix broken filters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants