I have a custom modal with custom buttons as props.
const [selection,setSelection] = useState(null)
const onSelect = (item) => {
setSelection(item);
Gui.PickOption({
message: 'choose an action',
buttons: BUTTONS,
onPress,
});
};
BUTTONS = [{buttonText:'print selection', onPress:()=> console.log(selection)}]
the issue here is that when the user presses the button, the log will be NULL because it seems that the modal has the state before the "selection" was updated. why doesn't it updated? how to make BUTTONS keep up with state changes? ( keep in mind the code above is a small example for an issue I am currently facing) , essentially I want the onPress to always perform set "tasks" with the most "current" state. )