Answer the question
In order to leave comments, you need to log in
Generic Popup in React?
Hello. I decided to learn React at my leisure (before that there was Angular, ExtJS, backbone and a bunch of other small things), but I constantly stumble upon some, it seems to me, dubious solutions. Well, for example, you need to write a universal Popup (a floating component that closes other floating components when opened) and use it to write other components (ContextMenu, Dropdown, Window, Overlay, etc.). As it was before:
- There are components Popup and Controller.
- When opening a Popup, it tells the Controller "Hey! I'm open!"
- Controller closes other already open Popups.
We wrote once and never remember this controller again. You may not even be aware of its existence. How to do something similar in React?
Answer the question
In order to leave comments, you need to log in
A pure react project is usually divided into components, and in order to establish a connection between them, you will have to define everything through the portal in the head component (yes, it’s so cool to make all pop-ups through it) and already replace the necessary content inside it.
Thus, you will have one universal pop-up for all occasions in life.
But I would connect redux and, based on the global state, without dropping millions of props, I would make a pop-up, as described in the comments
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question