SpreadSheet Functions not getting updated data.

Posted by: 16pa1a0576 on 2 June 2021, 6:18 pm EST

  • Posted 2 June 2021, 6:18 pm EST


    Here, i am attaching sample react code.In which, i tried to update state by clicking on a button. I was able to see the updated state in spreadsheet, but in the function cellDoubleClick , i was not getting updated data.

    Can you help me resolving in this issue ?
  • Replied 2 June 2021, 6:26 pm EST

  • Replied 3 June 2021, 7:50 pm EST


    Thanks for sharing the code. what happening here is inside the cellDoublemethod it has the closure of data at the time it was created so updating the data is not reflecting at the closure.

    We could solve the issue in two ways. we may use Refs and update refs every time the data got changed.

    The second approach is use the getDataSource method.

    Please refer to the following update sample that demonstrates both the solution.

    sample: https://codesandbox.io/s/laughing-bardeen-5enkk?file=/src/index.js

  • Replied 3 June 2021, 8:49 pm EST


    Can you once check, i have updated the code. In cellDoubleClickHandler i was calling a function passed as a prop. But, in that function when i console the state, i was not getting updated state. Can you share, me the reason for this behaviour ?

    This would be a great help.
  • Replied 6 June 2021, 10:42 pm EST


    The mentioned issue is the same closure issue explained previously by the avinash, you may use reacts refs to fix this. Please refer to the following updated sample:

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels