GithubHelp home page GithubHelp logo

Support params about mobx-react-router HOT 2 CLOSED

leesiongchan avatar leesiongchan commented on July 26, 2024 4
Support params

from mobx-react-router.

Comments (2)

andrefox333 avatar andrefox333 commented on July 26, 2024 2

I wish it did support params as well but if I really need it in my component, I decorate it withwithRouter from react-router-dom.

import { withRouter } from 'react-router-dom';

@withRouter
export default class MyComponent extends Component {
  render() {
    const { match } = this.props; 
    // what you will get from withRouter 
    // which has a bunch of router configs and the params itself.
    ...
  }
}```

from mobx-react-router.

alisd23 avatar alisd23 commented on July 26, 2024 1

Hi, good question.

Well I know for sure that react-router-redux (which this is very much based off) doesn't include params in the global store. I think it's because params are parsed when the route matches not when the location changes - the latter being what this library listens to. To get the params into state, we'd have to hook into the route component matching itself, which would require a pretty big rewrite of the API.

I suppose you could quite easily make some higher order component which wraps your route components, the sets the params in your store when the route changes.

from mobx-react-router.

Related Issues (20)

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.