Skip to content

Commit 0108fae

Browse files
authored
chore: upgrade to v3.2.0 (#1)
1 parent 9af0ff2 commit 0108fae

9 files changed

Lines changed: 3577 additions & 4360 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Continuous Integration
2+
3+
on: [push, pull_request]
4+
5+
permissions:
6+
contents: read
7+
8+
jobs:
9+
continuous-integration:
10+
runs-on: ubuntu-latest
11+
timeout-minutes: 15
12+
steps:
13+
- uses: actions/checkout@v7
14+
15+
- uses: actions/setup-node@v7
16+
with:
17+
node-version-file: .nvmrc
18+
cache: npm
19+
20+
- name: Install dependencies
21+
run: npm ci
22+
23+
- name: Lint
24+
run: npm run lint
25+
26+
- name: Build web application
27+
run: npm run build

‎.nvmrc‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
24

‎README.md‎

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
# Welcome to your Expo app 👋
1+
# Featurevisor with React Native
22

3-
This is an [Expo](https://expo.dev) project created with [`create-expo-app`](https://www.npmjs.com/package/create-expo-app).
3+
This Expo application uses the [Featurevisor React SDK](https://featurevisor.com/docs/react/) with React Native. The root layout creates a Featurevisor instance, loads a published datafile, and provides the instance to React components.
44

55
## Get started
66

77
1. Install dependencies
88

99
```bash
10-
npm install
10+
npm ci
1111
```
1212

1313
2. Start the app
@@ -16,35 +16,20 @@ This is an [Expo](https://expo.dev) project created with [`create-expo-app`](htt
1616
npx expo start
1717
```
1818

19-
In the output, you'll find options to open the app in a
19+
The output provides options to open the application in a:
2020

2121
- [development build](https://docs.expo.dev/develop/development-builds/introduction/)
2222
- [Android emulator](https://docs.expo.dev/workflow/android-studio-emulator/)
2323
- [iOS simulator](https://docs.expo.dev/workflow/ios-simulator/)
2424
- [Expo Go](https://expo.dev/go), a limited sandbox for trying out app development with Expo
2525

26-
You can start developing by editing the files inside the **app** directory. This project uses [file-based routing](https://docs.expo.dev/router/introduction).
26+
The Featurevisor evaluation is shown in `app/(tabs)/index.tsx`.
2727

28-
## Get a fresh project
28+
## Checks
2929

30-
When you're ready, run:
31-
32-
```bash
33-
npm run reset-project
30+
```sh
31+
npm run lint
32+
npm run build
3433
```
3534

36-
This command will move the starter code to the **app-example** directory and create a blank **app** directory where you can start developing.
37-
38-
## Learn more
39-
40-
To learn more about developing your project with Expo, look at the following resources:
41-
42-
- [Expo documentation](https://docs.expo.dev/): Learn fundamentals, or go into advanced topics with our [guides](https://docs.expo.dev/guides).
43-
- [Learn Expo tutorial](https://docs.expo.dev/tutorial/introduction/): Follow a step-by-step tutorial where you'll create a project that runs on Android, iOS, and the web.
44-
45-
## Join the community
46-
47-
Join our community of developers creating universal apps.
48-
49-
- [Expo on GitHub](https://github.com/expo/expo): View our open source platform and contribute.
50-
- [Discord community](https://chat.expo.dev): Chat with Expo users and ask questions.
35+
The build command exports the web application and provides a reproducible CI check without requiring a simulator.

‎app/(tabs)/index.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export default function HomeScreen() {
2323
<ThemedView style={styles.stepContainer}>
2424
<ThemedText type="subtitle">Feature evaluation:</ThemedText>
2525
<ThemedText>
26-
Feature "baz" is {isFeatureEnabled ? "enabled" : "disabled"}.
26+
Feature baz is {isFeatureEnabled ? "enabled" : "disabled"}.
2727
</ThemedText>
2828
</ThemedView>
2929
<ThemedView style={styles.titleContainer}>

‎app/_layout.tsx‎

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,63 @@
11
import { FeaturevisorProvider } from "@featurevisor/react";
2-
import { createInstance } from "@featurevisor/sdk";
2+
import { createFeaturevisor } from "@featurevisor/sdk";
3+
import { useFonts } from "expo-font";
4+
import { Stack } from "expo-router";
35
import {
46
DarkTheme,
57
DefaultTheme,
68
ThemeProvider,
7-
} from "@react-navigation/native";
8-
import { useFonts } from "expo-font";
9-
import { Stack } from "expo-router";
9+
} from "expo-router/react-navigation";
1010
import { StatusBar } from "expo-status-bar";
11+
import { useEffect, useState } from "react";
1112
import "react-native-reanimated";
1213

1314
import { useColorScheme } from "@/hooks/useColorScheme";
1415

1516
const DATAFILE_URL =
1617
"https://featurevisor-example-cloudflare.pages.dev/production/featurevisor-tag-all.json";
1718

18-
const f = createInstance({
19+
const f = createFeaturevisor({
1920
context: { userId: "123" },
2021
});
2122

22-
fetch(DATAFILE_URL)
23-
.then((res) => res.json())
24-
.then((datafileContent) => f.setDatafile(datafileContent));
25-
2623
export default function RootLayout() {
2724
const colorScheme = useColorScheme();
25+
const [datafileLoaded, setDatafileLoaded] = useState(false);
2826
const [loaded] = useFonts({
2927
SpaceMono: require("../assets/fonts/SpaceMono-Regular.ttf"),
3028
});
3129

32-
if (!loaded) {
33-
// Async font loading only occurs in development.
30+
useEffect(() => {
31+
let active = true;
32+
33+
fetch(DATAFILE_URL)
34+
.then((response) => {
35+
if (!response.ok) {
36+
throw new Error(`Request failed with status ${response.status}`);
37+
}
38+
39+
return response.json();
40+
})
41+
.then((datafileContent) => {
42+
if (active) {
43+
f.setDatafile(datafileContent, true);
44+
}
45+
})
46+
.catch((error) => {
47+
console.error("Could not load Featurevisor datafile:", error);
48+
})
49+
.finally(() => {
50+
if (active) {
51+
setDatafileLoaded(true);
52+
}
53+
});
54+
55+
return () => {
56+
active = false;
57+
};
58+
}, []);
59+
60+
if (!loaded || !datafileLoaded) {
3461
return null;
3562
}
3663

‎components/HapticTab.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { BottomTabBarButtonProps } from '@react-navigation/bottom-tabs';
2-
import { PlatformPressable } from '@react-navigation/elements';
1+
import type { BottomTabBarButtonProps } from "expo-router/js-tabs";
2+
import { PlatformPressable } from "expo-router/react-navigation";
33
import * as Haptics from 'expo-haptics';
44

55
export function HapticTab(props: BottomTabBarButtonProps) {

‎components/ui/TabBarBackground.ios.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useBottomTabBarHeight } from '@react-navigation/bottom-tabs';
1+
import { useBottomTabBarHeight } from "expo-router/js-tabs";
22
import { BlurView } from 'expo-blur';
33
import { StyleSheet } from 'react-native';
44

0 commit comments

Comments
 (0)