0

we need to create a modal dialog with overlay background in Reactjs as React components.when the user click on the overlay ,the modal should be closed.we need to create the modal in a way that it is reusable React component. somebody plz guide me home i can implement this

2
  • Take a look at react-bootstrap - it implements the functionality you are searching for. Commented Apr 20, 2016 at 15:47
  • do you want this modal to contain always the same html (jsx) structure or specific html for each case? Commented Apr 29, 2016 at 12:32

2 Answers 2

2

I highly recommend strolling through react-modal's source https://github.com/reactjs/react-modal for "how to" implement your own.

I've gone down this route of implementing custom modals from scratch a few times myself now, and I must recommend simply pulling in react-modal rather than attempting to reinvent that same wheel [I've since replaced homegrown implementations w/ react-modal]. I've experimented w/ a few different React modal packages and react-modal is fully customizable, battle tested, and has a great API.

I have answered nearly identical questions here: How to: ES6 React Modal and here: React conditional render pattern with some more thoughts/examples/links.

Sign up to request clarification or add additional context in comments.

Comments

0

Just for alternative route you could use the new <dialog> element, the browser support is rather low (http://caniuse.com/#search=dialog), but with polyfill this could be fixed. But this gives quite easy and extendable way to create dialogs, see demo here.

1 Comment

This is the first I've heard of a native dialog element. Wow, that is going to be amazing once browser support catches up! I'm going to have to keep an eye on this one.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.