| #
b31f747d |
| 03-Jul-2023 |
Mark Lawlor <[email protected]> |
feat: add generated types for Expo Router useSegment (#22629)
# Why
* Add type generation for Expo Router's `useSegment`
* Adds code comments and renames a few internal types.
* Refactored the
feat: add generated types for Expo Router useSegment (#22629)
# Why
* Add type generation for Expo Router's `useSegment`
* Adds code comments and renames a few internal types.
* Refactored the `useSearchParams` types
* Add default to `Href<T>`
Note that this is not a breaking change as the generated types are only
present inside the users' cache and should not be committed. Next time
the user starts the dev server they will get the new generated types.
## Questions
@EvanBacon Given the route `/(app)/note/[note]/` does useSegments return
the group?
## `useSearchParams`
This hook was a bit strange as its signature changed when you enabled
types routes.
Without: `useSearchParams<T extends Record<string, string>(): T`
With: `useSearchParams<T extends Route>(): SearchParams<T>`
This PR updates the TypedRoutes version to accept either a `Route` or a
`Record`. This `Record` is still typed checked and it must satisfy a
possible SearchParams object.
For example
```tsx
// This will only work if you have a [test] route somewhere in your app
const { test } = useSearchParams<{ test: string }>()
```
I quite like this as it allows you to cherry-pick the param that you
need.
Note that this obviously doesn't do a runtime check for it maybe be
correct, but its a start.
## Href<T>
Href<T> has a default value and by default now represents all possible
Hrefs. You can use the generic to reduce it down.
---------
Co-authored-by: evanbacon <[email protected]>
show more ...
|
| #
082815dc |
| 28-Jun-2022 |
Evan Bacon <[email protected]> |
chore: migrate config, config-plugins, config-types, prebuild-config (#17958)
|
| #
29975bfd |
| 28-Mar-2022 |
Evan Bacon <[email protected]> |
fix(cli): fix type errors (#16724)
* fix(cli): fix type errors
* Update CHANGELOG.md
* Update packages/@expo/cli/CHANGELOG.md
Co-authored-by: Expo Bot <[email protected]
fix(cli): fix type errors (#16724)
* fix(cli): fix type errors
* Update CHANGELOG.md
* Update packages/@expo/cli/CHANGELOG.md
Co-authored-by: Expo Bot <[email protected]>
* fix typecheck
* Update yarn.lock
* Update package.json
* Update MetroTerminalReporter.ts
Co-authored-by: Expo Bot <[email protected]>
show more ...
|
| #
8d307f52 |
| 23-Mar-2022 |
Evan Bacon <[email protected]> |
chore: refactor `expo/cli` to `@expo/cli` package (#16717)
* chore: refactor `expo/cli` to `@expo/cli` package
* Update CODEOWNERS
* fix linking
* fix lint script
* fix build file
* f
chore: refactor `expo/cli` to `@expo/cli` package (#16717)
* chore: refactor `expo/cli` to `@expo/cli` package
* Update CODEOWNERS
* fix linking
* fix lint script
* fix build file
* fix e2e tests
* lint before build
* use mock version
show more ...
|