Hi, I am Dhairya, I work with Guneet.
This is the same code as the solution you posted: https://codesandbox.io/p/devbox/handsontable-forked-9z845z.
The only change I made is adding a log inside afterSetCellMeta to track updates to cellMeta. However, I noticed that when I log the Map, it still shows the previous state instead of reflecting the latest update.
Here’s my implementation:
const cellMeta: Map<
string,
{
row: number;
col: number;
[key: string]: any;
}
> = new Map();
const afterSetCellMeta = (row, col, key, value) => {
const mapKey = `${row},${col}`;
const metaRow = cellMeta.get(mapKey);
if (metaRow) {
cellMeta.set(mapKey, { [key]: value, ...metaRow });
} else {
cellMeta.set(mapKey, { row, col, [key]: value });
}
console.log("Updated cell meta:", cellMeta);
};
code sanbox link of my implementation: https://codesandbox.io/p/devbox/handsontable-forked-mqjjpg?file=%2Fapp%2Fpage.tsx%3A30%2C36
The issue is that cellMeta doesn’t reflect the latest state when logged inside afterSetCellMeta. Instead, it always shows the previous state. It seems like the Map isn’t updating immediately.
Can you suggest a way to get the updated state correctly?
Below is the screen shot to help you identify the issue better.