Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gas-buddy/react-navigation-codegen
Type safe code generation for react-navigation based apps
https://github.com/gas-buddy/react-navigation-codegen
Last synced: about 2 months ago
JSON representation
Type safe code generation for react-navigation based apps
- Host: GitHub
- URL: https://github.com/gas-buddy/react-navigation-codegen
- Owner: gas-buddy
- License: mit
- Created: 2020-08-04T18:18:45.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-03-17T01:08:56.000Z (10 months ago)
- Last Synced: 2024-11-02T07:52:01.221Z (3 months ago)
- Language: TypeScript
- Size: 275 KB
- Stars: 3
- Watchers: 5
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
react-navigation-codegen
========================![Node CI](https://github.com/gas-buddy/react-navigation-codegen/workflows/Node%20CI/badge.svg)
A simple code generator to turn somewhat abstract specifications into TypeScript code with information about your full navigation stack in a React Navigation based app. This avoids lots of magic strings in your code, gives you a sense of the actual navigation structure, and avoids repeating yourself in code as much as usual.
Input can be YAML, JS, JSON, or Typescript. Consider a typical navigation setup:
```
type RootStackParamList = {
Home: undefined;
Profile: { userId: string };
Feed: { sort: 'latest' | 'top' } | undefined;
};const RootStack = createStackNavigator();
```
With this module, you would specify as follows:
```
export default {
screens: {
Root: {
parameterListType: 'RootStackParamList',
screens: {
Home: {},
Profile: {
parameterType: '{ userId: string }',
},
Feed: {
parameterType: '{ sort: 'latest' | 'top' } | undefined',
}
}
}
}
}
```And now your code becomes:
```
const RootStack = createStackNavigator();
```
Perhaps not a massive improvement in the simple example, but as you scale, it gets harder to manage all the types, related types and constants for every navigator, AND you lose a notion of the structure of the navigation tree.