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

Fixed an issue with throwing an exception when HotTable component state is changed #10427

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions wrappers/react/src/hotTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,8 @@ class HotTable extends React.Component<HotTableProps, {}> {

const newGlobalSettings = this.createNewGlobalSettings();

// See `suspendRender` method call on Handsontable instance to understand this call.
this.hotInstance.resumeRender();
this.updateHot(newGlobalSettings);
this.displayAutoSizeWarning(newGlobalSettings);
}
Expand Down Expand Up @@ -504,6 +506,18 @@ class HotTable extends React.Component<HotTableProps, {}> {

const editorPortal = createEditorPortal(this.getOwnerDocument(), this.getGlobalEditorElement());

if (this.hotInstance !== null) {
// This render comes from update performed on React component (not the first render). In process of updating
// component some properties are set to `null` values as it's described in React's documentation:
// "React sets ref.current during the commit. Before updating the DOM, React sets the affected ref.current
// values to null. After updating the DOM, React immediately sets them to the corresponding DOM nodes.".
// Thus, any extra rendering coming from Handsontable (Core and plugins do it sometimes; wrote in Vanilla JS) and
// corresponding callbacks to their hooks cause executing wrapper's actions while React component isn't ready.
// The below call stops HOT from executing extra render. The `resumeRender` call should be done right after component update.
// console.log('suspendRender');
this.hotInstance.suspendRender()
}

return (
<React.Fragment>
<div ref={this.setHotElementRef.bind(this)} {...containerProps}>
Expand Down