Code Monkey home page Code Monkey logo

react-router-modal's Introduction

Table of Contents

react-router-modal

A simple way to handle showing modals with react-router version 4.

Component docs: https://github.com/davidmfoley/react-router-modal/blob/master/docs/react-router-modal.md

Examples: https://davidmfoley.github.io/react-router-modal-examples

Installation

Which version of react-router-modal should I use?

TL;DR: If you are using a version of react that is >= 16.3, you should use version 2.

  • react-router-modal version 1 works with react 15.0 and higher
  • react-router-modal version 2 works only with react 16.3 and higher

You can use yarn info react version or npm info react version, within your project directory, to find the version of react.

Version 2 uses react portals. This makes a few things nicer. The most notable difference is that context that is provided outside of modals works properly within modals.

Because portals are not available on many widely used versions of react, version 2 is currently pre-release.

Install version 1:

yarn add react-router-modal

or

npm install --save react-router-modal

Install version 2:

yarn add react-router-modal@next

or

npm install --save react-router-modal@next

Other required modules

You also need react-router-dom, version 4 or higher.

TBH, if you are looking at this package you probably already have these, but you might want to check for version compatibility.

react-router-dom version 4

For ex: yarn add react-router-dom react react-dom.

Getting started

To add react-router-modal to your app:

  1. Include the CSS for react-router-modal, found in this package at css/react-router-modal.css

If you are using webpack, you can do this:

import 'react-router-modal/css/react-router-modal.css';

Note that you can also copy this file or create your own css and specify your own class names.

  1. Add a <ModalContainer /> to your react application. This is where any shown modals are added to the DOM.

See also: https://github.com/davidmfoley/react-router-modal-examples/blob/master/src/App.js#L42

  1. Add a <ModalRoute /> to test your setup:
<ModalRoute path='/modal-test' parentPath='/'>
  Hello
</ModalRoute>
  1. Navigate to /modal-test in your app. You should see a Modal with the contents "Hello".

Gotchas

My modals are not showing at all

  1. Did you render a ModalContainer?

  2. Did you include the CSS to style the modals and their backdrops?

I see my modal content but the component "behind" it is not rendering.

To display a modal component "on top" of another component, both routes (the ModalRoute and the Route that renders the other component) must match.

If you are seeing modal content but the component that you expect to see "behind" the modal is not rendering, you should check for the following:

  1. Did you put both routes inside a <Switch />, so only one of them matches?

  2. Did you use exact on the <Route /> that contains the component that is meant to render "under" the modal?

Accessibility

Modals are rendered with the following attributes:

role="dialog"

aria-modal="true"

role="dialog"

The role of modals defaults to dialog. You can specify a different role, for example alertdialog:

  <Modal role='alertdialog' aria-label='Important Notice!>
    Something important here!
  </Modal>`

The role can also be set on <ModalRoute /> and <ModalLink />.

aria-*

You should use the following props to describe your modal content:

Any props set on <Modal />, <ModalRoute />, or <ModalLink /> that start with aria- will be rendered on the modal element.

For example:

<Modal aria-labelledby="modal-title" aria-describedby="modal-description">
  <h3 id="modal-title">Important Information</h3>
  <p id="modal-description">
    A description of the purpose of this modal. 
  </p>
  ... additional modal content here ...
</Modal>

See: W3 Modal Example

Examples

TL;DR Example

import { ModalContainer, ModalRoute } from 'react-router-modal';
import { BrowserRouter, Link } from 'react-router-dom';

// assumes webpack loader for css
// ... or include this css however you do that in your project ...
import 'react-router-modal/css/react-router-modal.css'

function FooModal() {
  return <div>FOO</div>;
}

function BarModal() {
  return <div>BAR</div>;
}

function Example() {
 return (
   <BrowserRouter>
     <div>
       <Link to='/foo'>show foo</Link>
       <Link to='/bar'>show bar</Link>

       <ModalRoute component={FooModal} path='/foo' className='test-modal test-modal-foo'/>
       <ModalRoute component={BarModal} path='/bar' className='test-modal test-modal-bar'/>

       <ModalContainer />
     </div>
   </BrowserRouter>
 );
}

ModalContainer

Container for rendered modals.

This should be included in your react app as one of the last elements before the closing body tag. When modals are rendered, they live inside this container. When no modals are shown, nothing is rendered into the DOM.

Parameters

  • props Props
    • props.modalClassName String class name to apply to modals (optional, default react-router-modal__modal)
    • props.backdropClassName String class name to apply to modal backdrops (optional, default react-router-modal__backdrop)
    • props.containerClassName String class name to apply to the container itself (optional, default react-router-modal__container)
    • props.bodyModalOpenClassName String class name to apply to the when any modals are shown (optional, default react-router-modal__modal-open)
    • props.onFirstModalMounted Function? handler invoked when first modal is shown
    • props.onLastModalUnmounted Function? handler invoked when last modal is hidden
    • props.autoRestoreScrollPosition boolean Automatically restore the window scroll position when the last modal is unmounted. This is useful in cases where you have made the body position fixed on small screen widths, usually to work around mobaile browser scrolling behavior. Set this to false if you do not want this behavior. (optional, default true)
    • props.modalInClassName String class name applied to modal immediately after it is shown to allow for css transitions (optional, default react-router-modal__modal--in)
    • props.modalOutClassName String class name applied to modal before modal is hidden to allow for css transitions (optional, default react-router-modal__modal--out)
    • props.backdropInClassName String class name applied to backdrop immediately after it is shown to allow for css transitions (optional, default react-router-modal__backdrop--in)
    • props.backdropOutClassName String class name applied to backdrop before modal is hidden to allow for css transitions (optional, default react-router-modal__backdrop--out)
    • props.modalWrapperClassName String class name applied to backdrop before modal is hidden to allow for css transitions (optional, default react-router-modal__wrapper)
    • props.outDelay String delay, in milliseconds to wait when closing modal, to allow for css transitions to complete before ripping it out of the DOM (optional, default 0)

Examples

Using default class names

<ModalContainer />

Overriding the default class names

<ModalContainer
  bodyModalOpenClassName='modal-open'
  containerClassName='modal-container'
  backdropClassName='modal-backdrop'
  modalClassName='modal'
/>

DOM structure

// Note that modals are made "modal" via CSS styles, and end up rendered like the following in the DOM (with two modals, for example):
<div className={containerClassName}>
  <div>
    <div className={backdropClassName} />
    <div className={modalClassName}>
      .. bottom-most modal contents ..
    </div>
  </div>
  <div>
    <div className={backdropClassName} />
    <div className={modalClassName}>
      .. top-most modal contents ..
    </div>
  </div>
</div>

ModalRoute

A react-router Route that shows a modal when the location pathname matches.

Parameters

  • routeProps
  • props Object
    • props.path String path to match
    • props.exact Boolean If set, only show modal if route exactly matches path.
    • props.parentPath String path to navigate to when backdrop is clicked
    • props.onBackdropClick String Handler to invoke when backdrop is clicked. If set, overrides the navigation to parentPath, so you need to handle that yourself.
    • props.className String class name to apply to modal container
    • props.children Children modal content can be specified as chld elements
    • props.component ReactComponent modal content can be specified as a component type. The component will be passed parentPath and closeModal props, in addition to the specified props, and the withRouter props.
    • props.props Object Props to be passed to the react component specified by the component property.
    • props.inClassName String class name applied to modal immediately after it is shown to allow for css transitions (optional, default react-router-modal__modal--in)
    • props.outClassName String class name applied to modal before modal is hidden to allow for css transitions (optional, default react-router-modal__modal--out)
    • props.backdropClassName String class name applied to backdrop (optional, default react-router-modal__backdrop)
    • props.backdropInClassName String class name applied to backdrop immediately after it is shown to allow for css transitions (optional, default react-router-modal__backdrop--in)
    • props.backdropOutClassName String class name applied to backdrop before modal is hidden to allow for css transitions (optional, default react-router-modal__backdrop--out)
    • props.outDelay String delay, in milliseconds to wait when closing modal, to allow for css transitions to complete before ripping it out of the DOMWhen the route matches, the modal is shown. If multiple routes match, the modals will be stacked based on the length of the path that is matched.The component rendered in the modal will receive the following props: (optional, default 0)
  • parentPath string Either the parentPath specified in the ModalRoute, or a calculated value based on matched url
  • closeModal string A convenience method to close the modal by navigating to the parentPath

Modal

Renders its contents in a modal div with a backdrop. Use Modal if you want to show a modal without changing the route.

The content that is shown is specified by either the "component" prop, or by child elements of the Modal.

Parameters

  • props Object
    • props.stackOrder Number order to stack modals, higher number means "on top"
    • props.children Children Modal content can be specified as chld elements
    • props.component Component React component to render in the modal.
    • props.props Object props to pass to the react component specified by the component property
    • props.onBackdropClick Function handler to be invoked when the modal backdrop is clicked
    • props.className String class name to apply to modal container
    • props.inClassName String class name applied to modal immediately after it is shown to allow for css transitions
    • props.outClassName String class name applied to modal before modal is hidden to allow for css transitions
    • props.backdropInClassName String class name applied to backdrop immediately after it is shown to allow for css transitions
    • props.backdropOutClassName String class name applied to backdrop before modal is hidden to allow for css transitions
    • props.outDelay String delay, in milliseconds to wait when closing modal, to allow for css transitions to complete before ripping it out of the DOM

Examples

Modals using a component and props, vs. child elements

const Hello = ({ who }) => (<div>Hello {who}!</div>);

// component and props
const ComponentExample = () => (
  <Modal
   component={Hello}
   props={{ who: 'World' }}
  />
);

// using child elements
const ChildrenExample = () => (
  <Modal>
    <Hello who='World' />
  </Modal>
);

Specifying stack order

<div>
  <Modal
    className='top-component-modal'
    component={MyTopComponent}
    props={ { foo: 'bar'} }
    stackOrder={2}
  />
  <Modal
    component={MyBottomComponent}
    props={ { bar: 'baz'} }
    stackOrder={1}
  />
</div>

ModalLink

Link and ModalRoute in one convenient component Renders a link that, when clicked, will navigate to the route that shows the modal.

Parameters

  • props Object
    • props.path String path to match
    • props.exact Boolean If set, only show modal if route exactly matches path.
    • props.parentPath String path to navigate to when backdrop is clicked
    • props.linkClassName String class name to apply to
    • props.modalClassName String class name to apply to modal container
    • props.children Children Link contents. Note that Modal content must be specified by the component property.
    • props.component ReactComponent Component to render in the modal.
    • props.props Object Props to be passed to the react component specified by the component property.

Examples

Example ModalLink

<ModalLink path='/hello' component={HelloComponent}>
  Say Hello
</ModalLink>

react-router-modal's People

Contributors

davidmfoley avatar squidsoup avatar vineetsgr7 avatar

Stargazers

 avatar  avatar Andrey avatar Carlos Aguinaga avatar Matt Heslington avatar Anton Saladkou avatar Prince Owusu avatar Eralp Karaduman avatar Hunter Liu avatar  avatar Roman Vasilev avatar Jony Popov avatar Bui Thanh Ba Vuong avatar Cam Neely avatar Vikram Mevasiya avatar Yony avatar Byun Sanghee avatar Roman Hossain Shaon avatar ik5 avatar Yota Toyama avatar Dondoko Susumu avatar Jafar Rezaei avatar Umit Celik avatar Adam Klepacz avatar Al Ramadhan avatar Magoz avatar Daniel Santiago avatar Kirill Artihovich avatar Helge Drews avatar  avatar Ali avatar Daniel Sam avatar Damian avatar Konrad Albrecht avatar  avatar Franklin Gitonga avatar pmtea avatar Ahmet avatar Nick Smith avatar Tauqeer avatar Son Tran avatar Jin Wang avatar Satendra Rai avatar Regis Biron avatar Scott Horn avatar Larry Okeke avatar  avatar Stanislav Zhukovskiy avatar Shawn Wáng /wɔŋ/ avatar Wojtek Cichoradzki avatar Danny avatar Stef Lewandowski avatar  avatar Galymzhan Abdugalimov avatar Gapur Kassym avatar Иван avatar  avatar Ta David Yu avatar Valera avatar Chris Lonardo avatar Ali Hmer  avatar Leila Hadj-Chikh avatar Michael Jeries avatar Benjamin Keating avatar Md. Masum Billah avatar Mateusz Bagiński avatar Clement Fradet Normand avatar Shane Dyer avatar Sabin Tudor avatar Albin Ekblom avatar Qasem Hajizadeh avatar Patrick Paul avatar Kyohei Shimozato avatar Frantisek Elias avatar Dean (딘) avatar gwendall avatar Nelreina avatar  avatar Brian Frisch avatar Atty Eleti avatar Felipe Mansilla avatar Davide avatar  avatar Lucas Mórawski avatar Russell Keith BF avatar Jie Li avatar Mehmet Seven avatar Vladislav Katsura avatar Paweł Lula avatar Achille avatar teddav avatar sagar talla avatar Marcin Kasprowicz avatar JP Pincheira avatar Jeong Seong Dae avatar Rojay Simpson avatar Marco Nicolodi avatar Yuki Kodama avatar Bruno Bertolini avatar João Marins avatar

Watchers

 avatar James Seymour-Lock avatar James Cloos avatar Dean (딘) avatar Md. Masum Billah avatar  avatar  avatar

react-router-modal's Issues

Parent path with param

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.

License

Could you please update the license for this repo ?
Is it MIT ?

Usage with preact

Hi, i'm trying to use this with preact and i get an error described here
If outDelay is 0 the bug doesn't happen, when you add a delay it triggers the above error

The error is in this line

Changing the if condition to fixes the problem:

if (!modals || modals.length === 0) {
  return null;
}

I don't know if this is the right fix or if it's another thing that's not right
@davidmfoley what do you think ?
Also @developit i saw that you answered that stackoverflow question, do you have any idea ?

Not visible on small screens

I'm using react-router-modal in my project, and so far it seems to work fine everywhere I tested. Except it doesn't seem to work on Safari in iOS12. Please note that I did not test it with earlier versions of iOS or with a MacOS. The component that I have given to ModalRoute includes text fields, and basically the text fields are present there, but nothing is visible.

modalWrapperClassName is ignored

the property "modalWrapperClassName" is ignored on the ModalContainer, current reference that works seems to be "wrapperClassName". either the documentation is incorrect or the reference is.

Broken link to example code

I'm trying out the examples linked to from the readme here: https://davidmfoley.github.io/react-router-modal-examples/basic

The 'View Source' link points to https://github.com/davidmfoley/react-router-modal-examples/blob/masyoutter/src/examples/basic/ which does not exist.

I checked out the code and found that https://github.com/davidmfoley/react-router-modal-examples/blob/master/src/examples/basic/index.js has the correct link.

Maybe this means the site code just needs to be rebuilt somehow.

closeModal and BackdropClick should not add a new entry to the history

closeModal and BackdropClick should behave exactly the same as clicking back button on a browser. Adding a new history entry is very confusing for the user especially on Android mobile devices where the native back button is used extensively. I don't see any use case where adding the new history entry on close a modal is useful.

Close modal by onClick

Hi really like this module.

Is it possible to close the modal by onClick?

Such as <h1 onClick={___}>Test</h1>

Close Modal?

Firstly, great project and thanks!

I am trying to find the easiest way to hide a modal after opening. May be worth adding this to the documentation, currently I only see clicking the backdrop as the only easy way.

Once modal is closed the previous URL parameter is reset

Hi there!
I've made a simple routing system which handles the language param in a URL.
So if I type website.com/xx - > the appropriate language will be loaded.
website.com will load a default language. Pretty straightforward logic.

If I type website.com/en/modal1 the modal1 will be opened with English translation, what is good,
But the problem comes when I close the modal. The URL website.com/en/modal1 is reset to website.com without language parameter.

Is there a way to keep the URL parameter once the modal will be closed?
Or it should be a new feature?

Thanks!

Possibility of connecting the modal route component with Redux

Its possible?
Hello, I use this react-router-modal as route component of my user info modal and I have problem with connecting my component with redux.
Here is my User Container code which connects as route component to ModalRoute:

export namespace User {
  export interface Props extends RouteComponentProps<void> {
    user: UserStoreState;
    actions: typeof UserActions;
  }
}
@connect(mapStateToProps, mapDispatchToProps)
export default class User extends React.Component<User.Props>{
  constructor(props){
    super(props);
  }
  render(){
    console.log(this.props.user);
    return (
      <div className='modal user'>
        <label className="user-name">LOL</label>
        <button className="close-modal-button">
          <span className='button-bar'/>
          <span className='button-bar'/>
        </button>
      </div>
    )
  }
}


function mapStateToProps(state){
    return {
        user: state.user
    }
}
function mapDispatchToProps(dispatch){
    return {
        actions: bindActionCreators(UserActions as any, dispatch)
    }
}

Displays to console: undefined...

And there I wrote ModalRoute and ModalContainer

    <ModalRoute className='user-modal' path="/user/:userId" parentPath='/search?query=Mankubus'
                    component={() => <AsyncComponent
                      moduleProvider={user}/>}/>
        <ModalContainer history={history}/>

If you will talk about AsyncComponent , its worked with my others routes :)

<Route path="/game" component={() => <AsyncComponent
     moduleProvider={playground}/>}>
</Route>
<Route path="/search" component={() => <AsyncComponent
    moduleProvider={search}/>}>
</Route>

And sorry for my bad english ))

Parent route does not show when modal is opened

When a link is clicked that routes to a modal, I can't get the parent path to show in the background like in the examples. The modal itself shows fine and when clicking the backdrop it does go back to the parent route.

I'm using connected-react-router and redux.

CSS missing semicolons

(42:15) Missed semicolon

  40 |   }
  41 |   .react-router-modal__container {
> 42 |     position: absolute
     |               ^
  43 |     top: 0;
  44 |     left: 0;

Missing code in readme

In you're readme, you're keeping out key example code such as how to import the required modules, for example; using <ModalContainer /> requires:
import { ModalContainer } from 'react-router-modal';

Make a modal route mount last

Hi, would it be possible to make a ModalRoute always mount last via a prop?
For example for when you need the modal behind to finish loading before mounting the front one.

Input field loses focus

Any ideas why an input field would lose focus after onChange is fired only in a ModalRoute?
container:

...
onChange = (event) => {
        this.setState({
            ...this.state,
            formIsDirty: true,
            values: {
                ...this.state.values,
                [event.target.getAttribute('field')]: event.target.value
            }
        });
    }

render() {
       return <ModalRoute path={ '*/event/' + (this.state.values.id ? 'edit/' + this.state.values.id : 'create') } parent={ '/content' }
            component={ () =>
                <div>
                    ...
                    <Edit
                        isEditing={ this.state.isEditing }
                        onDateChange={ this.onDateChange }
                        onDelete={ this.onDelete }
                        onSubmit={ this.onSubmit }
                        onChange={ this.onChange }
                        values={ this.state.values }
                    />
                    ...
                </div>
            } />;
    }
...

Edit looks like:

const Edit = ({ isEditing, onChange, onDateChange, onDelete, onSubmit, values }) => {
    return(
        <Grid
            container
            spacing={ 40 }
            direction={ 'row' }
            align={ 'left' }
            justify={ 'center' }
            style={ styles.container }
        >
            ...
            <input value={ values.title } field={ 'title' } type={ 'text' } placeholder={ 'enter the title of the event here...' } style={ styles.text } onChange={ onChange } />;
            ...
    );
};

i've also tried using onKeyPress and onKeyUp but same result

How to ONLY render the modal and not RE-RENDER the route behind the modal

Hi,

You wrote in your main doc page: 'To display a modal component "on top" of another component, both routes (the ModalRoute and the Route that renders the other component) must match.'

The downside is that when the modal is opened, the parent route's components are re-rendered which is a waste and slows down the modal's rendering! My parent route loads a heavy menu page. How can I stop the parent from re-rendering AND open the modal which has its own route?

ability to specify background-content

I want to make modals that have their own route, if you route to them directly, but also show the page underneath them as whatever was loaded when the user clicked the link, and if the user clicks the backdrop it goes back to the page they were on before.

I am using react-router-last-location like this:

const Router = ({ lastLocation }) => (
  <Fragment>
    <Switch>
      <Route exact path='/' component={PageHome} />
      <Route exact path='/features' component={PageFeatures} />
      <Route exact path='/stories' component={PageStories} />
      <Route exact path='/pricing' component={PagePricing} />
      <Route exact path='/logout' component={PageLogout} />
      <Route exact path='/about' component={PageAbout} />
      <Route exact path='/terms' component={PageTerms} />
    </Switch>
    <ModalRoute path='/login' parentPath={lastLocation ? lastLocation.pathname : '/'} component={PageLogin} />
    <ModalRoute path='/register' parentPath={lastLocation ? lastLocation.pathname : '/'} component={PageRegister} />
    <ModalRoute path='/forgot' parentPath={lastLocation ? lastLocation.pathname : '/'} component={PageForgot} />
  </Fragment>
)

this works pretty well, but because everything is set to exact, nothing shows when the modals are visible, but all the other stuff works. When I turn off exact and re-arrange all the links so / is last, it displays the homepage underneath, not the lastRoute.

I made a codesandbox to illustrate

Here is what I am trying to accomplish:

  • If the user comes straight to /login route, show / behind it.
  • If the user clicks off the modal, show the link they were on before (or /, if they came straight there)
  • If the user clicks the /login link from another page, keep that page under the login modal

Items 1&2 work great, it's just the last one. I am thinking a new prop like bgComponent or something would make sense, or maybe just show parentPath underneath, as well as when they click off.

Keep origin scroll position when hitting the backdrop

Hey there!
I implemented the modal on a list view. I can open the modal perfectly by clicking on a list item. The problem is when clicking the backdrop is that it navigates forward to the original list view instead of actually going back causing it to loose the scroll pretty much starting over the top of the list. I guess it would be awesome to have a behaviour like the browser's back button which goes back and automatically scrolls to the original position of the list for when the item was clicked. Does that makes sense?

Thanks a lot for the good work!

Doesn't work with router once modal link defined in entry point and modal placed in another component

Hi!
I have a one-page website and a component called ‘Items’. In that component I’m using the react-router-modal.
Items.js:

function ModalsName(props) {
  return (
    <div className="modal-dialog modal-lg">
    </div>  
  );
}

class Items extends React.Component {
  render() {
    return (
      <div className="container">
              <Link to="/modalsurl"> </Link>
        <ModalLink component={ModalsName} path={`/modalsurl`} />
         …other links
      </div>
    )
  }
}

module.exports = translate()(Items);

In such way everything works just fine. The modal is accessible by it’s own URL.

But if I try to add a router to the entry point of my app - index.js. The problems occurs. Firstly the called modal doesn’t open – I see only blank screen without any errors. Once I come back to previous page it hangs with a preloader. Only F5 re-renders the page.
Index.js:

import { BrowserRouter, Route, Switch } from 'react-router-dom';
import { ModalContainer } from 'react-router-modal'; 

class App extends React.Component {

  render() {
    return (
        <LandingPage />
    )
  }
}


ReactDOM.render(
  <I18nextProvider i18n={i18n}>
    <BrowserRouter>
      <div>
        <Route exact path="/" component={App} />
        <ModalLink path="/modalsurl" component={Items} />        
        <Route component={NoMatch} />
      </div>
    </BrowserRouter>
  </I18nextProvider>,
  document.getElementById('app')
);

It seems like a bug...

Use React Portals

React Portals solves how to render a Modal on top of every component

Transition animation?

First of all, thanks for the library! I was just about to create the same exact thing.
What do you think about supporting transitions here? (Like fade in/fade out)

Unable to access dynamic params from child component

Hey,

I'm using react-router-dom 4 with react-router-modal and I have a dynamic segment/parameter in my route like this:

<ModalRoute
  parentPath="/"
  path="/users/:userId"
  component={UserProfile}
/>

and my child component is as simple as follows:

const UserProfile = props => {
  return <div>{props.match.params.userId}</div>
}

When I visit:
http://localhost/users/3234

The modal is being displayed as:
<div>undefined</div>

I expect to have the match with the parameter {userId: 3234} and path to be /users/3234. However, the params object is empty, and the path is "/"

Am I doing something wrong?

How do I access match.params from UserProfile?

Handle escape key

Provide auto-handling of escape, as requested by @johnhult, or add a full-fledged dialog example with esc key handling.

Component is unmounted before outDelay is over

Hi everyone!
Here is an example:
<ModalRoute component={Component} path="/path" />
<ModalContainer backdropClassName="modal__backdrop" modalClassName="modal modal_animation_to-right" modalInClassName="modal_in" modalOutClassName="modal_out" outDelay={30000} />

When navigate to /path modal gets modal_in class. Then click 'Back' button in browser => modal gets modal_out class and Component unmount immediately, then after 30000s modal unmounts too. Is it normal behavour? I expect Component to be unmounted at the same time with modal after outDelay.

Also the last modal unmounting without any delay specified in outDelay.

Using

  • react 16.6.3
  • react-router 4.3.1
  • react-router-modal 2.0.0-rc2

How to use with react-router-config?

How do I specify the modal router in this type of structure?

const routes = [
  {
    component: Root,
    routes: [
      {
        path: "/",
        exact: true,
        component: Home
      },
      {
        path: "/child/:id",
        component: Child,
        routes: [
          {
            path: "/child/:id/grand-child",
            component: GrandChild
          }
        ]
      }
    ]
  }
];

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.