Skip to content

useSearchParams disregards optional properties #422

Description

@MrVauxs

Change Type

Correction

Proposed Changes

When using a useSearchParams with a schema containing .optional properties, these properties are never reflected in the URL. This should be mentioned on the docs, if it isn't a bug.

Basic example:

export const craftingSearchSchema = z.object({
	tab: z.enum(["harvesting", "manufacturing", "enchanting", "forging"]).default("harvesting"),
	table: z.string().optional(),
});

The table prop will never show up in the url. tab will. Changing table to use a default("") makes it appear.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions