Skip to content

Commit

Permalink
modify use-locaton
Browse files Browse the repository at this point in the history
  • Loading branch information
jeetiss committed Mar 21, 2021
1 parent df73b52 commit f9ce93f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
3 changes: 2 additions & 1 deletion demo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ const getQuery = (key) => {
const clamp = (min, value, max) => Math.min(max, Math.max(min, value));

const Player = () => {
const [search] = useLocation();
const { search } = useLocation();

const [state, update] = useReducer((a, b) => ({ ...a, ...b }), {
loaded: false,
frames: [],
Expand Down
9 changes: 7 additions & 2 deletions demo/use-location.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,12 @@ export default ({ base = "" } = {}) => {
[base]
);

return [pathAndSearch.search, navigate];
const locationApi = [pathAndSearch.path, navigate]
locationApi.path = pathAndSearch.path
locationApi.search = pathAndSearch.search
locationApi.update = update

return locationApi;
};

// While History API does have `popstate` event, the only
Expand All @@ -83,4 +88,4 @@ if (typeof history !== "undefined") {
const currentPathname = (base, path = location.pathname) =>
!path.toLowerCase().indexOf(base.toLowerCase())
? path.slice(base.length) || "/"
: "~" + path;
: "~" + path;

0 comments on commit f9ce93f

Please sign in to comment.