DEV Community

jser
jser

Posted on

create a Modal System with Context API in React

How to create a Modal System in React?

React Portals might be good but personally I'd like to separate the Modals from Screens, because the order information is not fixed for a modal, yet push and pop actions have the order info naturally.

So I recommend using Context API to create a Modal System, here is my super rough demo code: https://codesandbox.io/s/suspicious-f...​

And here is a video explaining:

https://www.youtube.com/watch?v=s20TOqXjVqk

Hope it helps.

Top comments (0)