Open fongandrew opened 1 month ago
That's good point! What do you think about this API:
const { hook, searchHook } = memoryLocation({ path: '/foo?key=value' });
<Router hook={hook} searchHook={searchHook}>
// or more explicit
const { hook, searchHook } = memoryLocation({ path: '/foo', searchPath: 'key=value' });
Added this to our feature backlog.
Yeah, returning a searchHook
is what I'd expect here. As to the implicit vs explicit form, either works. Thanks!
When using memory location for testing purposes, query params returned by
useSearch
are ignored:I assume this happens because no
searchHook
is passed toRouter
here, butmemoryLocation
does not appear to have one.As a temp workaround, I can swap
useSearch()
with something likeuseLocation()[0].split('?')[1]
or specify my own search hook with the query param built in, but it'd be nice not to.