Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove dependency on hashchange event #455

Closed
3 tasks
SgtPooki opened this issue Oct 29, 2024 · 0 comments · Fixed by #457
Closed
3 tasks

fix: remove dependency on hashchange event #455

SgtPooki opened this issue Oct 29, 2024 · 0 comments · Fixed by #457
Assignees
Labels
effort/hours Estimated to take one or several hours exp/intermediate Prior experience is likely helpful kind/architecture Core architecture of project P0 Critical: Tackled by core team ASAP status/ready Ready to be worked

Comments

@SgtPooki
Copy link
Member

SgtPooki commented Oct 29, 2024

While integrating [email protected] into ipfs-webui, I ran into an issue because ipfs-webui is using createRouteBundle from redux-bundler. In order to get the ExplorePage working properly, I had to window.dispatchEvent(new Event('hashchange')) when redux-bundler provides an updated url from the selectRouteInfo selector.

We need to decouple the hash-change event, so projects consuming these components can provide the current explore path and force updates and re-renders as appropriate. We don't want to require this property on the ExploreProvider because it would force consumers to render that provider wherever their url change logic is.

potential solutions

  1. Provide a forceRefresh function in ExploreContextProps
  2. Accept a url prop to ExplorePage and ensure ExploreContextProps is updated when a new url is received.
  3. Ensure doExploreUserProvidedPath updates exploreState:
    const doExploreUserProvidedPath = (path: string): void => {
    const hash = path != null ? `#/explore${ensureLeadingSlash(path)}` : '#/explore'
    window.location.hash = hash
    }

Recommended approach

  • We should do item 3 above so users can call useExplore and then doExploreUserProvidedPath with whichever path
  • we should not require consumers to use #/explore paths
  • we should remove all hashchange listeners and window.location.path expectations.
@SgtPooki SgtPooki added the need/triage Needs initial labeling and prioritization label Oct 29, 2024
@SgtPooki SgtPooki self-assigned this Oct 29, 2024
@SgtPooki SgtPooki added exp/intermediate Prior experience is likely helpful P0 Critical: Tackled by core team ASAP kind/architecture Core architecture of project effort/hours Estimated to take one or several hours status/ready Ready to be worked and removed need/triage Needs initial labeling and prioritization labels Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort/hours Estimated to take one or several hours exp/intermediate Prior experience is likely helpful kind/architecture Core architecture of project P0 Critical: Tackled by core team ASAP status/ready Ready to be worked
Projects
No open projects
Status: No status
Development

Successfully merging a pull request may close this issue.

1 participant