react-router-modal icon indicating copy to clipboard operation
react-router-modal copied to clipboard

Parent path with param

Open Sexual opened this issue 6 years ago • 2 comments

Is there a way for the parent path to have a param in it like the example below?

path="/image/:id/comments" parentPath="/image/:id"

Doing this does not work, hence I believe that the parent path logic isn't the same as the one used in react router as when you click the backdrop, it will redirect to /image/:id without the actual ID.

Sexual avatar Jul 25 '18 21:07 Sexual

Good feature request. In the meantime, there is an undocumented workaround: you can provide a function for parentPath and it will be invoked with the current Match and the result will be used as the parentPath.

davidmfoley avatar Jul 25 '18 23:07 davidmfoley

@davidmfoley indeed doing something like the below option does work.

parentPath={(match) => `/image/${match.params.id}`}

I'll look into getting a pull request done with a solution for it.

Sexual avatar Jul 26 '18 00:07 Sexual