Skip to content

Releases: xiel/use-location-state

v3.1.2 - Batching Fixes

16 Nov 13:33
Compare
Choose a tag to compare
  • fix: batched reset bug #375 in #450
  • fix: batching in next in #451

Full Changelog: v3.1.1...v3.1.2

Support for Next.js

23 Sep 12:45
Compare
Choose a tag to compare

What's Changed

  • feat: Support Next.js by @xiel in #419 (fixes #414)
  • fix: Upgrade node to v18 by @xiel in #417
  • chore: Updated dependencies

Next.js Support

Import from use-location-state/next to use the router build into Next.js, which enables you to use the query state also during SSR.

import { useQueryState } from 'use-location-state/next'

export { getServerSideProps } from 'use-location-state/next' // [1]

export default function Page() {
  const [count, setCount] = useQueryState('count', 0)
  //...
}

[1] Page must be server rendered (SRR), otherwise React warns about a hydration mismatch, when your initial rendering depends on the query state. Export your own getServerSideProps function or the provided empty one.


Full Changelog: v3.0.1...v3.1.1

Support react-router v6

13 Nov 11:37
Compare
Choose a tag to compare
  • Add Support for react-router v6
    • API stayed the same, you just need to upgrade to the new major version of react-router (^6.0.0)
    • Thanks to @gitter-me for opening the issue (#230)
    • Checkout their fancy new docs: https://reactrouter.com

Full Changelog: v2.5.0...v3.0.0

Reset using null

29 Oct 18:40
Compare
Choose a tag to compare
  • you can now reset the query string and receive the defaultValue by calling the setter with null
const [name, setName] = useQueryState('name', 'Sarah')

  // eg. in some click callback
  setName('Felix')

  // ... later you want to reset back to the default value, you can just call
  setName(null) 

useQueryReducer + useLocationReducer

29 Jun 18:22
Compare
Choose a tag to compare
  • lets you control a query/location state using a reducer, dispatch and actions
  • currently available on the next tag

vanilla

yarn add use-location-state@next

react-router

yarn add react-router-use-location-state@next

SSR bugfix 🐛

08 Oct 20:49
Compare
Choose a tag to compare
  • fixes a bug where (SSR) build with gatsby / node would crash due to missing btoa thx @bitttttten (#94)

useLocationState()

22 Sep 10:10
Compare
Choose a tag to compare
  • useLocationState(name, defaultValue) was added 🎉
    • restores the latest value after navigation actions (back/forward), by keeping value in history.state
    • supported value types: string | number | boolean | Date | Array | Object
    • handles complex & nested values - all values that can be serialized are supported

v2.2.0

16 Sep 16:09
Compare
Choose a tag to compare
  • method option (push/replace) in set function is now also supported for hash query strings
const [value, setValue] = useQueryState('itemName', 'default value')
<button onClick={() => setValue('a pushed value', { method: 'push' })}>...</button>
  • fix: stale state after change in other component #79

v1.0.2

23 Apr 15:09
Compare
Choose a tag to compare

Bug Fixes

  • package: update @types/node to version 11.13.7 (0973706)
  • package: update react-scripts to version 3.0.0 (c80d054)
  • Detached git HEAD (98c5715)
  • lerna version remove beta preid (did not work anyway) (6c05f3d)

Features

  • use-location-state: add useLocationHashQueryStringInterface hook (4d61250)
  • use-location-state: add useLocationHashQueryStringInterface hook (0ca3601)
  • useLocationHashQueryState: provide new exports useLocationHashQueryState and useLocationHashQu (666aa4a), closes #20

BREAKING CHANGES

  • useLocationHashQueryState: renamed exports, queryState and setQueryState are now all returned as array tuples

v1.0.0

23 Apr 15:08
Compare
Choose a tag to compare
v1.0.0 Pre-release
Pre-release

Bug Fixes

  • package: update @types/node to version 11.13.7 (0973706)
  • package: update react-scripts to version 3.0.0 (c80d054)
  • Detached git HEAD (98c5715)
  • lerna version remove beta preid (did not work anyway) (6c05f3d)

Features

  • use-location-state: add useLocationHashQueryStringInterface hook (4d61250)
  • use-location-state: add useLocationHashQueryStringInterface hook (0ca3601)
  • useLocationHashQueryState: provide new exports useLocationHashQueryState and useLocationHashQu (666aa4a), closes #20

BREAKING CHANGES

  • useLocationHashQueryState: renamed exports, queryState and setQueryState are now all returned as array tuples