-
Notifications
You must be signed in to change notification settings - Fork 811
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rendering multiple modals #798
Comments
Any update on this? I also ran into an issue with having multiple |
If You can archive the same result by moving the modal outside of the Product. Something like this should work.. const Product = ({ item, onClick }) => (
<button onClick={() => onClick(item)}>Open {item.title}</button>
);
const App = () => {
const [currentProduct, setProduct] = useState(null);
return (
<>
{products.map((product, index) => (
<Product item={product} key={index} onClick={setProduct} />
))}
<Modal
closeTimeoutMS={300}
isOpen={Boolean(currentProduct)}
onRequestClose={() => setProduct(null)}
>
<button onClick={() => setProduct(null)}>Close</button>
<h2>{currentProduct.title}</h2>
</Modal>
</>
);
}; |
@diasbruno since it seems that each |
@amille14 maybe you can use |
You can try to get the |
Ah ok, I think I can make |
Your solution worked for me. Thanks a lot <3 |
@giacomoalonzi This is the expected behavior. Each modal you instantiate will create a node element where the modal will be placed when it opens up. It's still open a feature request to allow react-modal to reuse the same node. PRs are always welcome! |
@diasbruno Is this still an open issue? |
Summary:
I have a grid of products, each with its own modal for quick shop functionality.
I came across this issue, that suggests to conditionally render the modal. However, I would like to have a transition on the modal and according to the documentation the close transition will not run if the modal is conditionally rendered.
#75
Expected behavior:
One instance of
ReactModalPortal
rendered on pageLink to example of issue:
Here is a minimal example of the transition in effect with multiple
ReactModalPortal
components rendered.https://codesandbox.io/s/amazing-kalam-q4zv6?fontsize=14&hidenavigation=1&theme=dark
The text was updated successfully, but these errors were encountered: