Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions packages/wouter/src/use-browser-location.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,18 @@ export const useLocationProperty = (fn, ssrFn) =>

const currentSearch = () => location.search;

export const useSearch = ({ ssrSearch = "" } = {}) =>
useLocationProperty(currentSearch, () => ssrSearch);
export const useSearch = ({ ssrSearch } = {}) =>
useLocationProperty(
currentSearch,
ssrSearch != null ? () => ssrSearch : currentSearch
);

const currentPathname = () => location.pathname;

export const usePathname = ({ ssrPath } = {}) =>
useLocationProperty(
currentPathname,
ssrPath ? () => ssrPath : currentPathname
ssrPath != null ? () => ssrPath : currentPathname
);

const currentHistoryState = () => history.state;
Expand Down