Code Monkey home page Code Monkey logo

Comments (4)

Dean177 avatar Dean177 commented on May 30, 2024

Yes, the router you use shouldn't have any impact on functionality/

Are you encountering unexpected behaviour

from use-url-state.

vcardins avatar vcardins commented on May 30, 2024

Hi Dean, thanks for the quick reply. Yes, I noticed that it removes the hash route:

I decorated my class component like
const MyPagePageWithUrlState = withUrlState(() => Utils.getSearchParams())(MyPage);

then when I click on a link to that page
http://localhost/#/page?&filter1=2190&filter2=2&filter3=q4...
it loads the page but replaces the URL to
http://localhost/?&filter1=2190&filter2=2&filter3=q4#/page (not the har route it was to the end)

Any advice?

from use-url-state.

Dean177 avatar Dean177 commented on May 30, 2024

Are you using the v1.0.0-alpha.0? If not, perhaps give that a shot first.

If the newer version isn't working either you can pass a history object as a config parameter, it needs to have the following signature:

type UnregisterCallback = () => void

export type HistoryAdapter = {
  listen: (listener: () => void) => UnregisterCallback
  location: Location
  push: (location: Location) => void
  replace: (location: Location) => void
}

// Maybe your hash router has a compatible API that would let you use it like so:
let hashHistory = {
  listen: (listener) => hashRouter.listen(listener)
  location: hasRouter.location,
  push: (location) => hashRouter.push(location)
  replace: (location) => hashRouter.replace(location)  
}

What are you using for routing?

from use-url-state.

vcardins avatar vcardins commented on May 30, 2024

Thanks, Dean! I'll try that. I'm using React Router 5.1.2.

from use-url-state.

Related Issues (13)

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.