Giter VIP home page Giter VIP logo

Comments (3)

alisd23 avatar alisd23 commented on July 26, 2024

Hey thanks for the issue (and for the great detail) - good find.

My first question is: what is the case for passing the history property from a RouterStore instance in to a Router component, as opposed to just passing the return history value from syncHistoryWithStore as the README example does? i.e:

const browserHistory = createBrowserHistory();
const routingStore = new RouterStore();

const stores = {
  // Key can be whatever you want
  routing: routingStore,
  // ...other stores
};

const history = syncHistoryWithStore(browserHistory, routingStore);

ReactDOM.render(
  <Provider {...stores}>
    <Router history={history}>
      <App />
    </Router>
  </Provider>,
  document.getElementById('root')
);

Maybe I'm missing a use case.

But in general I think your current workaround is the correct implementation anyway - meaning the history and location properties should be required in the typings:

export class RouterStore {
  history: History;
  location: Location;
}

Would this solve the problem?

Even though technically those properties can be undefined/null, using this library as described in the docs would mean that any useful application of using the a RouterStore would be in situation where the history and location properties have been set (at any point after the syncHistoryWithStore function call).

from mobx-react-router.

JReinhold avatar JReinhold commented on July 26, 2024

Well, I had just posted the issue when I realized that the "correct" way is to use the history returned from syncHistoryWithStore, so I guess there is no use case for it.

But anyway, I agree with you that we should probably just change the typings to be required no matter what. That would fix the issue (would also mean we wouldn't have to check for undefined everywhere, yay!)

from mobx-react-router.

alisd23 avatar alisd23 commented on July 26, 2024

Added in release 4.0.3

https://github.com/alisd23/mobx-react-router/releases/tag/v4.0.3

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.