Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions my-app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Learn more https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files

# dependencies
node_modules/

# Expo
.expo/
dist/
web-build/
expo-env.d.ts

# Native
.kotlin/
*.orig.*
*.jks
*.p8
*.p12
*.key
*.mobileprovision

# Metro
.metro-health-check*

# debug
npm-debug.*
yarn-debug.*
yarn-error.*

# macOS
.DS_Store
*.pem

# local env files
.env*.local

# typescript
*.tsbuildinfo
66 changes: 66 additions & 0 deletions my-app/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { useEffect, useState } from "react";
import { StatusBar } from "expo-status-bar";
import { StyleSheet, Text, TouchableOpacity, View } from "react-native";
import * as configCat from "@configcat/sdk/browser";
import { PollingMode, IConfigCatClient } from "@configcat/sdk/browser";

export default function App() {
const [featureFlagValue, setFeatureFlagValue] = useState(false);

useEffect(() => {
const configCatClient = configCat.getClient(
"C-HdCN7xrUmB6kDjUpl3Rw/q87GdulGfU6Vtj8TKvu4-Q",
PollingMode.AutoPoll,
{
pollIntervalSeconds: 10,
}
);

getAndSetFeatureFlagValue(configCatClient);

configCatClient.on("configChanged", function () {
getAndSetFeatureFlagValue(this.configCatClient);
});

return () => configCatClient.dispose();
}, []);

function getAndSetFeatureFlagValue(configCatClient: IConfigCatClient) {
configCatClient.getValueAsync("signupButton", false).then((value) => {
setFeatureFlagValue(value);
});
}

return (
<View style={styles.container}>
<TouchableOpacity style={styles.button}>
<Text>LOGIN</Text>
</TouchableOpacity>
{featureFlagValue ? (
<TouchableOpacity style={styles.button}>
<Text>SIGNUP</Text>
</TouchableOpacity>
) : null}
<StatusBar style="auto" />
</View>
);
}

const styles = StyleSheet.create({
container: {
backgroundColor: "#fff",
flex: 1,
flexDirection: "column",
justifyContent: "center",
alignItems: "center",
},
button: {
backgroundColor: "#4CBE72",
borderRadius: 10,
margin: 12,
height: 40,
width: 200,
justifyContent: "center",
alignItems: "center",
},
});
29 changes: 29 additions & 0 deletions my-app/app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"expo": {
"name": "my-app",
"slug": "my-app",
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/icon.png",
"userInterfaceStyle": "light",
"newArchEnabled": true,
"splash": {
"image": "./assets/splash-icon.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"ios": {
"supportsTablet": true
},
"android": {
"adaptiveIcon": {
"foregroundImage": "./assets/adaptive-icon.png",
"backgroundColor": "#ffffff"
},
"edgeToEdgeEnabled": true
},
"web": {
"favicon": "./assets/favicon.png"
}
}
}
Binary file added my-app/assets/adaptive-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added my-app/assets/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added my-app/assets/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added my-app/assets/splash-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions my-app/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { registerRootComponent } from 'expo';

import App from './App';

// registerRootComponent calls AppRegistry.registerComponent('main', () => App);
// It also ensures that whether you load the app in Expo Go or in a native build,
// the environment is set up appropriately
registerRootComponent(App);
Loading