react-spreadsheet
react-spreadsheet copied to clipboard
Improve formula updating
Formula updating is buggy with the latest versions of React
@iddan any idea what the issue is?
I have the case where values are not getting updated unless you focus on that cell. Is this issue related to that?
I believe it is.
I tried to dig into it. Wasn't able to figure out the problem. However, I noticed that this is not buggy in the website version which makes me think maybe it is related to https://github.com/iddan/react-spreadsheet/issues/70. Didn't find the source for the gh-pages so couldn't verify the version of react that was used on it.
Some one know if have a version that don't occur this bug? I'm using 0.4.48
I looked into it further. React version used on https://iddan.github.io/react-spreadsheet/ is v16.8.6 so in fact it is not related to https://github.com/iddan/react-spreadsheet/issues/70. So I am not sure what gives. Maybe it is the react-spreadsheet version and this bug creeped in later and the website is using earlier version.
The gh-pages branch's latest commit is on May 7, 2019. So it is probably using react-spreadsheet v0.4.32
Thanks for the information @meetmangukiya I tried on v0.4.32, but the bug continues, I noticed that when my table starts with a formula the bug occurs, but if the formula is reissued the bug does not occur. Maybe that's why it doesn't happen on the site
@mgotze i've raised a fix, you can add that version to your app and help test if it got fixed
Thats nice :D what version I can use? it's a v0.4.48?
yarn add @flamy-dev/react-spreadsheet
Oh, thanks!
@meetmangukiya here for me the same bug happens whit this behavor when table starts with a formula the bug occurs, but if the formula is edited the bug does not occur.
Not sure what you mean. Can you give an example, or what your data
is?
@meetmangukiya
For example
my table starts with this data
[{value: ''}, {value: ''}], [({value: ''}, {value: '=A1+B1'})],
then the bug occurs, but if I edit the formula after this directly on table, the bug doesn't happen anymore
try initializing with 0(not as a string) maybe?
Same problem
[ [{ value: 0 }, { value: 0 }], [{ value: 0 }, { value: '=A1+B1' }], ]
@meetmangukiya example: https://ibb.co/PCHxNj5
Yeah I think this has to do with bindings and the fact that the initial state of bindings is not set. They get set only on edit. @iddan can you change the initialization to set the initial bindings? I am a bit hazy as to how bindings are working. But pretty sure it has to do with the fact the initialization of state does not set bindings and they only get set on editing of cells; for that cell.
Hey @meetmangukiya and @mgotze. Thank you for using React Spreadsheet. At the moment I'm really busy so I can't get the time to update the code but I would love to review a PR.
Hi @iddan It's awesome to use react-spreadsheet, too bad I don't have enough knowledge to make this correction, I really needed
I wont be fixing the bindings anytime soon. But the PR I raised fixes one bug I guess.
@iddan, so no idea when this bug will ne fixed?
I might get to it in a week. Right now I'm really busy.
Wow that optimistic, sorry 😅 . Last night I came up with a strategy that I think would make formula updating work as expected: Every time a cell renders it will update a matrix in the state of computed values and use the computed values of other cells to compute its value. That way if a cell updates it will trigger a re-render for all of its dependencies without keeping a graph of dependencies in the state.
Working on some other direction here: #214
Giving it a second try in #63
This is solved with [email protected]