Tuesday, December 10, 2019

Stateless Way of Handling Modal in React

You ever wanted to call your modal in React as you call builtin alert() method. It can be handy if you want to have a modal that able to be fired anywhere in your application and you don't want to mess with either render tree or redux store with all those actions to be dispatched etc.

Wouldn't be easier to have just show and hide your modal like this :

myModal.show();

myModal.hide();

Well, you can achieve this by injecting your component directly to HTML DOM.


Check full example :

No comments: