Skip to content

Custom versions of reactpy_router use_search_params that return parameters as a Pydantic data class.

use_search_params

The following search params can be converted into a fully typed Pydantic model as follows.

1
?hello=world&thing=1&thing=2
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
from pydantic import BaseModel
from reactpy import component, html

from reactpy_utils import use_search_params

class MyParams(BaseModel):
    hello: str | None = None
    thing: list[int] | None = None


@component
def App():
    params = use_search_params(MyParams)

    return html.h2(params.hello)

use_params

The following params can be converted into a fully typed Pydantic model as follows.


Last update: November 28, 2024
Authors: Steve Jones