-
Notifications
You must be signed in to change notification settings - Fork 0
Part 2: Integrating Gluestack UI
-
Open up your VSCode terminal and run the following command:
npx gluestack-ui init
-
Go through any prompts that pop up, and give wait for Gluestack UI to finish installing.
-
Observe that there is now a
components
directory in your working directory:
- Open your
App.tsx
file and observe that your<View/>
component has been wrapped in a<GluestackUIProvider/>
component. The indentation may be off - feel free to fix it to match the following code:The<GluestackUIProvider mode="light"> <View style={styles.container}> <Text>Count: {count}{Platform.OS == "android" && ' '}</Text> <Button title="Increase Count" onPress={() => setCount(count + 1)}/> <Button title="Decrease Count" onPress={() => setCount(count - 1)}/> <StatusBar style="auto" /> </View> </GluestackUIProvider>
<GluestackUIProvider/>
will provide styling for Gluestack UI components you use inside of it. You may need to restart your Expo Go preview for these changes to take effect.
-
Check out the Gluestack UI documentation to view their available components. Follow the instructions in the documentation to add the
Text
,Heading
, andButton
components to your project. -
Incorporate the
Text
,Heading
, andButton
components into your code. Add a<Heading/>
component above the<Text/>
component and fill it with the following text:Simple Counter
. For theText
andButton
components, you will need to update your imports to import those components from your components directory instead of'react-native'
. For theHeading
, you will need to add a new import statement. -
Edit the button code according to examples in Gluestack UI's documentation for the
Button
component. -
Restart your Expo Go preview. At this point, your app should look something like this:
Next up: Part 3