[GH #722] How to stop an invalid cell error state resetting when a parent component rerenders or state is updated in React

Tags: #<Tag:0x00007efc6b77a5b0> #<Tag:0x00007efc6b77a3d0>

Hi,

I have a very simple example here: https://codesandbox.io/p/sandbox/relaxed-solomon-253hk7?file=%2Fsrc%2Findex.js%3A34%2C15

In my project I need to update some state after handsontable updates in order to show some conditional logic based on the updated table data.

However, if the user inputs in invalid value into a field, the table will momentarily indicate this with the red cell, but then reset to white once the rerender happens.

Would appreciate some advice on how to keep this state in hot.

Thanks.

Hi @will.busby

I don’t have the access to this sandbox, can you please change the restrictions?

Sorry,

How about now?

https://codesandbox.io/p/sandbox/relaxed-solomon-253hk7?file=%2Fsrc%2Findex.js

@adrian.szymanski

@will.busby

Thank you. It seems that your setUpdater logic resets the state of the validator. Can you please tell more what is the purpose of this logic?

@adrian.szymanski So this example is just a very simple example of how it resets. I want to persist the validator state through state updates like this.

My real usage is using HOT and onChange updates a Context state further up the hierarchy which I need in order to show a live update elsewhere in the application. But doing this re-renders the table and the validator state is reset. I want to prevent the validator state from being reset

@will.busby

Thank you for the explanation. I checked it further and we have similar issues reported. The reason for this is that cell meta data is being reset on the state change. I’ll add your case to the report, but it’s worth mentioning that we are working on new version of our React wrapper which should fix those kind of issues, we hope to release it before the end of the year so I’ll let you know when it’s out if we don’t fix that issue before.

1 Like