Code Monkey home page Code Monkey logo

Comments (4)

quisido avatar quisido commented on July 1, 2024

That is what is happening now, see line 18.

In addition to listening on the Context, use-react-router adds code to re-render the component when the location changes. This is to bypass the problems with update blocking that react-router has.

If you could elaborate more on how your enhancement differs from this implementation, let me know. I'm not sure I understand fully your proposal.

from use-react-router.

mayconfsousa avatar mayconfsousa commented on July 1, 2024

For what I understand, the problem with updating blocking it's only about class components. Once that use-react-router is a hook and couldn't be used with class components, I don't think that we need to worry about that.

from use-react-router.

quisido avatar quisido commented on July 1, 2024

If I can get a unit test for re-rendering in response to location changes that bypasses scenarios where updates are usually blocked, I'd be more than happy to remove the unnecessarily pub-sub behavior.

from use-react-router.

avindra avatar avindra commented on July 1, 2024

The official hooks simply directly return the context:

https://github.com/ReactTraining/react-router/blob/bb9b4fdc597dc29b7451723a5351b6cd16d5c1be/packages/react-router/modules/hooks.js#L17-L28

And I can also confirm having shipped direct usage of the context to a widely used production app, that the "pub-sub" functionality you're looking for works "out of the box"

from use-react-router.

Related Issues (19)

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.