jeroenpelgrims / vue-use-query-param

Use url query parameter like regular refs in Vue, in a typesafe way.
9 stars 1 forks source link

Change default unset value to `undefined` instead of `null`. #3

Closed jeroenpelgrims closed 8 months ago

jeroenpelgrims commented 8 months ago

Currently when a query param is not set it will get the value null. It would be better if we would return undefined instead since we can then more easily use standard TS optional notation. (question mark) This way we don't have to transform the value from null to undefined first.

e.g.:

function foo(value?: string) {
...
}

const param = useQueryParam(stringParam());

foo(param.value);