[Code Demo] create Modal System with Context API in React | JSer - Front-End Interview questions

Опубликовано: 11 Октябрь 2024
на канале: JSer
5,860
62

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...

Hope it helps.

Hi I'm a JavaScript engineer who is not good at algorithms,
and currently practicing leetCode & BFE.dev. If you are interested, maybe we can learn together.