Closed stackoverfloweth closed 1 week ago
Name | Link |
---|---|
Latest commit | 0ce5a1a44147ad4c22b7acd5bb500ca56a165b86 |
Latest deploy log | https://app.netlify.com/sites/kitbag-router/deploys/667a2d7c493d54000892171c |
Deploy Preview | https://deploy-preview-208--kitbag-router.netlify.app |
Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify site configuration.
Alternative approach for tracking optional params without modifying param itself
With this PR, knowing if a param should be optional has nothing to do with the
Param
itself. We've always taken the name of a param from the string part of a path/query. IEpath('/something/[id]', {id: String})
for required string orpath('/something/[?id]', {id: String})
for optional string of the same name. We always strip the param name out from the[
and]
, we just now keep the?
if it's present.Previously our optional id param would be stored on the route as
Now will be stored as
Note, this key that now may start with "?" is only true internally. So when calling
path
orquery
, the 2nd argument does not expect a question markThis is also true for
router.push
type functions as well as reading params fromuseRoute
.This alternative approach means we can delete the entire
optional
function, types, and file altogether.