molefrog / wouter

🥢 A minimalist-friendly ~2.1KB routing for React and Preact

Home Page:https://npm.im/wouter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

wouter-preact: Params with typescript?

Nicolab opened this issue · comments

Hello,

There is a typescript error with the url parameters, example:

<Route
   path="/confirm/:token"
   component={ConfirmRegister}
 />
Capture d’écran 2023-11-11 à 13 00 11

I tried with a function:

Capture d’écran 2023-11-11 à 12 58 24

Of course I can use useParams but if there is a solution to keep props, I'm interested.
Any idea?

Hi @Nicolab, I can't reproduce this. Could you provide a code sandbox?

I found my error.
See my screenshot, with the callback it's the params defined (params) instead ({params}).

With the component passed directly, I need to define token prop as optional. It's not what I want but that works like this, because it's defined like this in Wouter.