-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create App.tsx at end of "createApp" command, since will depend on ot…
…her tasks (#25) When we create a new app using thoughtbelt, we will want to generate an `App.tsx` that has all of our providers and tools configured, including React Navigation, global state provider, styling provider, etc. To me, since this file will be tied to many different commands, it would make more sense for the creation of this file to be a step at the end of the `createApp` command, independent of any one command. If we run `thoughtbelt navigation` independently, we will not want to create a new `App.tsx` in that case, though it would likely be helpful to include some output directing the user to wrap their app in a `NavigationContainer`. What do you think? We don't yet have a mechanism for detecting if a given command is running independently as opposed to being a part of the main `createApp` (or other) command .
- Loading branch information
Stephen Hanson
authored
Dec 12, 2023
1 parent
2cdcb65
commit 1a2d6de
Showing
5 changed files
with
52 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { StatusBar } from 'expo-status-bar'; | ||
import { StyleSheet, Text, View } from 'react-native'; | ||
import Providers, { Provider } from 'src/components/Providers'; | ||
|
||
// Add providers to this array | ||
const providers: Provider[] = [ | ||
// CODEGEN:BELT:PROVIDERS - do not remove | ||
]; | ||
|
||
export default function App() { | ||
return ( | ||
<Providers providers={providers}> | ||
<View style={styles.container}> | ||
<Text>Open up App.js to start working on your app!</Text> | ||
<StatusBar style="auto" /> | ||
</View> | ||
</Providers> | ||
); | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
flex: 1, | ||
backgroundColor: '#fff', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { ReactNode } from 'react'; | ||
|
||
export type Provider = (children: ReactNode) => ReactNode; | ||
|
||
type ProvidersProps = { | ||
children: ReactNode; | ||
providers: Provider[]; | ||
}; | ||
|
||
export default function Providers({ children, providers }: ProvidersProps) { | ||
return providers.reverse().reduce((acc, current) => { | ||
return current(acc); | ||
}, children); | ||
} |