Open/close modal hook affects all modals on the page
FastStore
•
ID: 1042165
Backlog
Published on5/31/2024
•
Last updated on6/4/2024
1 min read
Summary
On opening/closing a modal the action affects all the modals of the page
Simulation
Try opening a modal on a page with more than one Look for the other modals, you'll see the behavior will be the same
Workaround
You can use a customized state instead of the native one. Here is an example:
import { useState } from "react";import { Modal, ModalHeader, ModalBody, LinkButton, Icon } from "@faststore/ui";import ModalContent from "./ModalContent";import section from "./styles.module.scss";const ModalSelector = () => {const [showModal, setShowModal] = useState(false);const ToggleModal = () => {setShowModal((showModal) => !showModal);};return (} > Delivery {showModal && ( <> )});};export default ModalSelector;