Skip to content
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

Fix Datagrid logs warning about invalid prop hasBulkActions of type array #6122

Merged
merged 1 commit into from
Apr 9, 2021
Merged

Conversation

RoBYCoNTe
Copy link
Contributor

@RoBYCoNTe RoBYCoNTe commented Apr 3, 2021

Prop hasBulkActions passed to DatagridBody was computed as "array" instead of boolean generating this console error:

Warning: Failed prop type: Invalid prop hasBulkActions of type array supplied to ForwardRef, expected boolean.

@OoDeLally
Copy link
Contributor

OoDeLally commented Apr 7, 2021

Same here.

It was introduced by d44d7a7#diff-edba3a2955ae4f00f365f75b18d43ae1b7d6a1a00c24fe63903fcd4ed679ec18R52.

It happens because hasBulkActions is guarded by the propType:

hasBulkActions: PropTypes.bool.isRequired

but DatagridBody is carelessly using JS's cast-to-boolean:

hasBulkActions: hasBulkActions && selectedIds,

so hasBulkActions ends up being an array.

Solution 1 (easy):

hasBulkActions: hasBulkActions && Boolean(selectedIds),

Solution 2 (harder but better): drop propTypes altogether and rely on Typescript, which already seems here anyway.

EDIT: Ah, I just saw #6122 :D

@fzaninotto fzaninotto merged commit 59f1943 into marmelab:master Apr 9, 2021
@fzaninotto
Copy link
Member

Thanks!

@fzaninotto fzaninotto added this to the 3.14.3 milestone Apr 9, 2021
@fzaninotto fzaninotto changed the title Fix hasBulkActions prop type passed to DatagridRow Fix Datagrid logs warning about invalid prop hasBulkActions of type array Apr 9, 2021
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.

None yet

3 participants