use-modals-back-navigation

Custom hook to handle closing modals, drawer and accordions when click the browser back button or the mobile native back button


Keywords
Modals, Frontend, Back button, React, React hooks
License
ISC
Install
npm install use-modals-back-navigation@1.0.0

Documentation

What is this?

Handle closing modals, drawers, accordions and any other components that open and close when clicking on the browser or the mobile back button.

Installation

npm i --save use-modal-back-navigation

Then...

import useModalBackNavigation from 'use-modal-back-navigation';

useModalBackNavigation({
    onClose: onClose,
    hash: 'modal-example', // or use any name that you want
    isModalOpen: isOpen
});