Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

wouter

Package Overview
Dependencies
Maintainers
1
Versions
97
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wouter - npm Package Compare versions

Comparing version
3.6.0
to
3.7.0
+18
-13
esm/use-hash-location.js

@@ -25,17 +25,22 @@ import { useSyncExternalStore } from './react-deps.js';

const navigate = (to, { state = null } = {}) => {
// calling `replaceState` allows us to set the history
// state without creating an extra entry
const navigate = (to, { state = null, replace = false } = {}) => {
const [hash, search] = to.replace(/^#?\/?/, "").split("?");
history.replaceState(
state,
"",
// keep the current pathname, but replace query string and hash
location.pathname +
(search ? `?${search}` : location.search) +
// update location hash, this will cause `hashchange` event to fire
// normalise the value before updating, so it's always preceeded with "#/"
(location.hash = `#/${hash}`)
);
const newRelativePath =
location.pathname + (search ? `?${search}` : location.search) + `#/${hash}`;
const oldURL = location.href;
const newURL = new URL(newRelativePath, location.origin).href;
if (replace) {
history.replaceState(state, "", newRelativePath);
} else {
history.pushState(state, "", newRelativePath);
}
const event =
typeof HashChangeEvent !== "undefined"
? new HashChangeEvent("hashchange", { oldURL, newURL })
: new Event("hashchange", { detail: { oldURL, newURL } });
dispatchEvent(event);
};

@@ -42,0 +47,0 @@

{
"name": "wouter",
"version": "3.6.0",
"version": "3.7.0",
"description": "Minimalist-friendly ~1.5KB router for React",

@@ -5,0 +5,0 @@ "type": "module",

@@ -48,3 +48,3 @@ <div align="center">

**[React-three-fiber](https://github.com/react-spring/react-three-fiber)**,
**[Sunmao UI](https://sunmao-ui.com/)**, **[Million](https://millionjs.org/)** and many more.
**[Sunmao UI](https://sunmao-ui.com/)**, **[Million](https://million.dev/)** and many more.

@@ -368,3 +368,3 @@ ## Table of Contents

```jsx
import { useSearchParams } from 'wouter-search';
import { useSearchParams } from 'wouter';

@@ -371,0 +371,0 @@ const [searchParams, setSearchParams] = useSearchParams();

import { Path } from "./location-hook.js";
export function navigate<S = any>(to: Path, options?: { state: S }): void;
export function navigate<S = any>(
to: Path,
options?: { state?: S; replace?: boolean }
): void;

@@ -5,0 +8,0 @@ export function useHashLocation(options?: {