solid-primitives icon indicating copy to clipboard operation
solid-primitives copied to clipboard

useLocationHash

Open jer3m01 opened this issue 2 years ago • 1 comments

Describe The Problem To Be Solved

reactively use location hash

Suggest A Solution

const locationHash = useLocationHash();

createEffect(() => {
  console.log(locationHash()); // => '#' + string
});

https://developer.mozilla.org/en-US/docs/Web/API/Window/hashchange_event

jer3m01 avatar May 07 '23 15:05 jer3m01

I was working on a url package long time ago, but dropped it because I didn't know what I was doing and solid-router provides similar functionality. But maybe it could be revived with a smaller, more focus scope. This it createLocationState which was kinda doing that: https://github.com/solidjs-community/solid-primitives/blob/url/packages/url/src/location.ts#L113

thetarnav avatar May 09 '23 17:05 thetarnav