I have researched on immediate state update using hooks and found this solution. However, I am finding a challenge implementing it in my case.
const rowEvents = {
onClick: (e, row, rowIndex) => {
setMessageid(row.pm_id);
console.log(row.pm_id);
console.log(messageid);
if (row.custompassword === true) {
handleShow1();
} else {
decipher();
handleShow2();
}
},
};
How do I get the current set state of messageid by adding it to useEffect so that it detects any changes? decipher() uses messageid therefore it needs to be current one.