-
Notifications
You must be signed in to change notification settings - Fork 990
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 #3476: DataTable: TypeError when adding and starting editing a new row #3664
Conversation
Thanks a lot for your contribution! But, PR does not seem to be linked to any issues. Please manually link to an issue or mention it in the description using #<issue_id>. |
components/lib/datatable/BodyCell.js
Outdated
@@ -463,14 +463,16 @@ export const BodyCell = React.memo((props) => { | |||
} | |||
}, [props.editingMeta]); | |||
|
|||
useUpdateEffect(() => { | |||
/* eslint-disable */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should not have to disable eslint?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't want to disable that, but I couldn't build it successfully, I'm not very familiar with react, please tell me how to do better
$ npm run build:lib
> primereact@8.7.3-SNAPSHOT build:lib
> NODE_ENV=production INPUT_DIR=components/lib/ OUTPUT_DIR=dist/ npm run build:package
> primereact@8.7.3-SNAPSHOT build:package
> npm run build:check && rollup -c && gulp build-resources && npm run build:api
> primereact@8.7.3-SNAPSHOT build:check
> npm run lint && npm run format:check && npm run type:check && npm run security:check && (NODE_ENV=test npm run test:check)
> primereact@8.7.3-SNAPSHOT lint
> next lint --max-warnings=0
./components/lib/datatable/BodyCell.js
473:8 Warning: React Hook React.useEffect has missing dependencies: 'editingKey', 'getCellCallbackParams', and 'props'. Either include them or remove the dependency array. However, 'props' will change when *any* prop changes, so the preferred fix is to destructure the 'props' object outside of the useEffect call and refer to those specific props inside React.useEffect. react-hooks/exhaustive-deps
@yanxiyue thanks for the fix can you also comment on the ticket so then I can assign it to you? |
@yanxiyue this should work... React.useEffect(() => {
if (props.editMode === 'cell' || props.editMode === 'row') {
const callbackParams = getCellCallbackParams();
const params = { ...callbackParams, editing: editingState, editingKey };
props.onEditingMetaChange(params);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [editingState]); |
got it. fixed. |
#3476
editingMeta
was not initialized in this specific case.editingMeta
will be updated byuseUpdateEffect
hook, whenBodyCell
'seditingState
changed.BodyCell
is not mounted yet, so, the update logic will not be executedTherefore,I try change
useUpdateEffect
toReact.useEffect
, it works well.