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

DataTable: TypeError when adding and starting editing a new row #3476

Closed
kalinkrustev opened this issue Oct 14, 2022 · 4 comments · Fixed by #3664
Closed

DataTable: TypeError when adding and starting editing a new row #3476

kalinkrustev opened this issue Oct 14, 2022 · 4 comments · Fixed by #3664
Assignees
Labels
Type: Bug Issue contains a defect related to a specific component.
Milestone

Comments

@kalinkrustev
Copy link
Contributor

Describe the bug

When adding a new row and immediately setting it in edit mode, an error Cannot read properties of undefined (reading 'data') is thrown in BodyCell EditorCallback. EditingMeta was not initialized in this specific case.

Reproducer

https://codesandbox.io/s/primereact-test-forked-224zjd?file=/src/index.js

PrimeReact version

8.6.1

React version

18.x

Language

ALL

Build / Runtime

Create React App (CRA)

Browser(s)

No response

Steps to reproduce the behavior

Use the reproducer URL, click to add a new row and start typing in one of the fields.

Expected behavior

No response

@kalinkrustev kalinkrustev added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Oct 14, 2022
@melloware
Copy link
Member

Were you going to submit a PR?

@melloware melloware added Type: Bug Issue contains a defect related to a specific component. and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Oct 14, 2022
@kalinkrustev
Copy link
Contributor Author

I was planning to, but haven't found a solution yet, as I had to handle other stuff first.

@kalinkrustev
Copy link
Contributor Author

I was using some workaround for some time (i.e. several months), but recently I found the workaround does not work in all cases.

@yanxiyue
Copy link
Contributor

  1. The cause seems to be that editingMeta was not initialized in this specific case.
  2. editingMeta will be updated by useUpdateEffect hook, when BodyCell's editingState changed.
  3. in this case, BodyCell is not mounted yet, so, the update logic will not be executed.

Therefore,I try change useUpdateEffect to React.useEffect, it works well. see PR #3664

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a defect related to a specific component.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants