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): Let it work even when selectedIds is undefined #5892

Merged
merged 1 commit into from
Feb 11, 2021

Conversation

jtomaszewski
Copy link
Contributor

Currently if we use Datagrid outside of List component (e.g. in a Show view), if we don't pass selectedIds={[]}, it throws such an error:

DatagridBody.js:52 Uncaught TypeError: Cannot read property 'includes' of undefined
    at DatagridBody.js:52
    at Array.map (<anonymous>)
    at DatagridBody.js:32
    at renderWithHooks (react-dom.development.js:14803)
    at updateForwardRef (react-dom.development.js:16816)
    at beginWork (react-dom.development.js:18645)
    at HTMLUnknownElement.callCallback (react-dom.development.js:188)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:237)
    at invokeGuardedCallback (react-dom.development.js:292)
    at beginWork$1 (react-dom.development.js:23203)
    at performUnitOfWork (react-dom.development.js:22154)
    at workLoopSync (react-dom.development.js:22130)
    at performSyncWorkOnRoot (react-dom.development.js:21756)
    at react-dom.development.js:11089
    at unstable_runWithPriority (scheduler.development.js:653)
    at runWithPriority$1 (react-dom.development.js:11039)
    at flushSyncCallbackQueueImpl (react-dom.development.js:11084)
    at flushSyncCallbackQueue (react-dom.development.js:11072)
    at batchedUpdates$1 (react-dom.development.js:21862)
    at Object.notify (Subscription.js:19)
    at Subscription.notifyNestedSubs (Subscription.js:92)
    at Subscription.handleChangeWrapper (Subscription.js:97)
    at Object.dispatch (redux.js:222)
    at e (<anonymous>:1:40553)
    at middleware.js:22
    at Object.dispatch (redux-saga-core.esm.js:1410)
    at dispatch (<anonymous>:1:28545)
    at performPessimisticQuery.js:50

which leads to this:

image

This commit should fix it I hope. Let Datagrid be mounted without that selectedIds prop, which can be empty array by default.

@fzaninotto fzaninotto merged commit e716365 into marmelab:master Feb 11, 2021
@fzaninotto
Copy link
Member

Thanks!

@fzaninotto fzaninotto added this to the 3.12.2 milestone Feb 11, 2021
@jtomaszewski jtomaszewski deleted the patch-1 branch April 19, 2021 02:26
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.

2 participants