SpreadSheet Functions not getting updated data

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

    • Post Options:
    • Link

    Posted 2 June 2021, 6:18 pm EST

    Hi,

    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 ?

  • Posted 2 June 2021, 6:26 pm EST

  • Posted 3 June 2021, 7:50 pm EST

    Hi,

    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

    Regards,

    Avinash

  • Posted 3 June 2021, 8:49 pm EST

    Hi,

    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.

    https://codesandbox.io/s/hopeful-stonebraker-vv3z0?file=/src/index.js

  • Posted 6 June 2021, 10:42 pm EST

    Hi,

    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:

    https://codesandbox.io/s/infallible-rain-hi8o8?file=/src/index.js

    Regards

Need extra support?

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

Learn More

Forum Channels