I have used Handsontable in a react application.
I need to open a pop-up on click of a certain button. To open the button I need to use react’s setState to set the variable to true.
When using the setState() in react, all the red highlighted cells are resetting back to a white.
I need to have that red highlighted cell as red even after setState() call.
Below is my sample code showing this issue:-
Enter any alphabetic characters in the column named “Number”. When it highlights as red(i.e. invalid). Click on the Click Me! button which is using setState() to add another variable in the object. Which is going to reset the red color to a white.
import React from ‘react’;
import { HotTable } from ‘@handsontable/react’;
import ‘handsontable/dist/handsontable.full.css’;
class App extends React.Component {
constructor(props) {
super(props);
this.state = {
settings: {
data: [
[1, 'a'],
[2, 'b']
],
colHeaders: ['Number', 'Text'],
columns: [
{type: 'numeric'},
{type: 'text'}
],
},
};
this.hotTableComponent = React.createRef();
}
handleClick = () => {
this.setState({
testValue: true,
});
}
render() {
return (
Click Me!
);
}
}
export default App;