Is it possible to create a direct link to a modal with React and Meteor?

I’m having a lot of fun building my first Meteor/React project. I was wondering if there is a way to create a direct link to a modal?

At the moment I have 3 pages which all have their own modals. I would like to create something like www.page.com/comments/modalId. So when people click on the link they are immediatly brought to the specific modal.

I am using react-router for the routing in my app but to be honest I would have no idea how to achieve this, if it’s even possible.

Anyone able to push me in the right direction?

Kind regards, Dominic

If your modal show and hide with state, then it seems that if it is initially in show state on the link then it will be already showing up when someone visits the link.

How do you change the state of an object via a link?

I’m not exactly sure of what you are asking (the link you provided doesn’t show a modal for me) but here are some thoughts:

  • have the initial show state as true in the component’s constructor
  • pass a prop to the constructor of true or false to put on show state
  • have two diff link urls with one already showing the modal

React Bootstrap can be helpful with modals.

I have been looking into doing something similar. Not sure if this will be helpful, but something I found is https://github.com/tajo/react-portal. This allows you to manage a separate react root, with a use case being modals. I haven’t worked with it much yet, but I imagine you can do something with a specific route that would hide/show a modal using this.

Cool thanks so much for taking the time to reply. I am going to check it out! I know it’s possible, I read that you can actually change the state of a component directly via the link, haven’t found out how yet though :slight_smile: