Bug report
Describe the bug
The onEscKeyDown function can be only provided once during the first initialization, it cannot be updated later.
To Reproduce
Create a function with useCallback which depends on some state variable.
const [ confirmationIsOpen, setConfirmationIsOpen ] = useState(true);
const onEscKeyDown = useCallback(() => {
console.log(confirmationIsOpen);
if (
confirmationIsOpen
) {
closeConfirmation();
} else {
closeModal();
}
}, [ closeModal, closeConfirmation, confirmationIsOpen ]);
useEffect(() => {
const timeout = setTimeout(() => setConfirmationIsOpen(false), 1000);
return(() => clearTimeout(timeout));
}, [ setConfirmationIsOpen ]);
return(<Modal ... onEscKeyDown={onEscKeyDown} />);
When the confirmationIsOpen variable is changed it will still log the initial value on ESC key presses.
Expected behavior
The function should be updated.
System information
- Version of react-responsive-modal: 6.4.2
Bug report
Describe the bug
The onEscKeyDown function can be only provided once during the first initialization, it cannot be updated later.
To Reproduce
Create a function with useCallback which depends on some state variable.
When the confirmationIsOpen variable is changed it will still log the initial value on ESC key presses.
Expected behavior
The function should be updated.
System information