1.0.0 • Published 5 years ago

@livestd/react-router-utils v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

NPM

Utils and hooks for react-router

Installation

npm install --save @livestd/react-router-utils

useQuery

interface Query {
  // properties
  params: Record<string, any>;
  // methods
  push: (params: {}) => void;
  replace: (params: {}) => void; // replace on history
}

// type
useQuery = (): Query;

Usage

import { useQuery } from '@livestd/react-router-utils';

const Component = () => {
  const {params, push} = useQuery();
  
  useEffect(() => console.log(params));
  
  const pushParam = () => {
    push({param: 1});
  };
  
  return (<button onClick={pushParam} />)
}
1.0.0

5 years ago