nandorojo / solito

🧍‍♂️ React Native + Next.js, unified.
https://solito.dev
MIT License
3.54k stars 181 forks source link

Update multiple params at once #275

Closed nandorojo closed 1 year ago

nandorojo commented 1 year ago
  const [direction, setDirection] = useParam('direction')
  const [order, setOrder] = useParam('order')

  const update = () => {
    setOrder('price')
    setDirection('asc')
  }

On Web, this will result in only direction updating, since navigation is interruptible. There should be some way to update multiple items at once. I'm thinking a useUpdate or useBatch hook could work:

const { useParam, useBatch } = createParam()

const batch = useBatch()

batch({
  order: 'price',
  direction: 'asc'
})
nandorojo commented 1 year ago

Released in 2.1.