Skip to content
Merged
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
27 changes: 27 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Continuous Integration

on: [push, pull_request]

permissions:
contents: read

jobs:
continuous-integration:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v7

- uses: actions/setup-node@v7
with:
node-version-file: .nvmrc
cache: npm

- name: Install dependencies
run: npm ci

- name: Lint
run: npm run lint

- name: Build web application
run: npm run build
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
24
35 changes: 10 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Welcome to your Expo app 👋
# Featurevisor with React Native

This is an [Expo](https://expo.dev) project created with [`create-expo-app`](https://www.npmjs.com/package/create-expo-app).
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.

## Get started

1. Install dependencies

```bash
npm install
npm ci
```

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

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

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

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

## Get a fresh project
## Checks

When you're ready, run:

```bash
npm run reset-project
```sh
npm run lint
npm run build
```

This command will move the starter code to the **app-example** directory and create a blank **app** directory where you can start developing.

## Learn more

To learn more about developing your project with Expo, look at the following resources:

- [Expo documentation](https://docs.expo.dev/): Learn fundamentals, or go into advanced topics with our [guides](https://docs.expo.dev/guides).
- [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.

## Join the community

Join our community of developers creating universal apps.

- [Expo on GitHub](https://github.com/expo/expo): View our open source platform and contribute.
- [Discord community](https://chat.expo.dev): Chat with Expo users and ask questions.
The build command exports the web application and provides a reproducible CI check without requiring a simulator.
2 changes: 1 addition & 1 deletion app/(tabs)/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default function HomeScreen() {
<ThemedView style={styles.stepContainer}>
<ThemedText type="subtitle">Feature evaluation:</ThemedText>
<ThemedText>
Feature "baz" is {isFeatureEnabled ? "enabled" : "disabled"}.
Feature baz is {isFeatureEnabled ? "enabled" : "disabled"}.
</ThemedText>
</ThemedView>
<ThemedView style={styles.titleContainer}>
Expand Down
49 changes: 38 additions & 11 deletions app/_layout.tsx
Original file line number Diff line number Diff line change
@@ -1,36 +1,63 @@
import { FeaturevisorProvider } from "@featurevisor/react";
import { createInstance } from "@featurevisor/sdk";
import { createFeaturevisor } from "@featurevisor/sdk";
import { useFonts } from "expo-font";
import { Stack } from "expo-router";
import {
DarkTheme,
DefaultTheme,
ThemeProvider,
} from "@react-navigation/native";
import { useFonts } from "expo-font";
import { Stack } from "expo-router";
} from "expo-router/react-navigation";
import { StatusBar } from "expo-status-bar";
import { useEffect, useState } from "react";
import "react-native-reanimated";

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

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

const f = createInstance({
const f = createFeaturevisor({
context: { userId: "123" },
});

fetch(DATAFILE_URL)
.then((res) => res.json())
.then((datafileContent) => f.setDatafile(datafileContent));

export default function RootLayout() {
const colorScheme = useColorScheme();
const [datafileLoaded, setDatafileLoaded] = useState(false);
const [loaded] = useFonts({
SpaceMono: require("../assets/fonts/SpaceMono-Regular.ttf"),
});

if (!loaded) {
// Async font loading only occurs in development.
useEffect(() => {
let active = true;

fetch(DATAFILE_URL)
.then((response) => {
if (!response.ok) {
throw new Error(`Request failed with status ${response.status}`);
}

return response.json();
})
.then((datafileContent) => {
if (active) {
f.setDatafile(datafileContent, true);
}
})
.catch((error) => {
console.error("Could not load Featurevisor datafile:", error);
})
.finally(() => {
if (active) {
setDatafileLoaded(true);
}
});

return () => {
active = false;
};
}, []);

if (!loaded || !datafileLoaded) {
return null;
}

Expand Down
4 changes: 2 additions & 2 deletions components/HapticTab.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BottomTabBarButtonProps } from '@react-navigation/bottom-tabs';
import { PlatformPressable } from '@react-navigation/elements';
import type { BottomTabBarButtonProps } from "expo-router/js-tabs";
import { PlatformPressable } from "expo-router/react-navigation";
import * as Haptics from 'expo-haptics';

export function HapticTab(props: BottomTabBarButtonProps) {
Expand Down
2 changes: 1 addition & 1 deletion components/ui/TabBarBackground.ios.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useBottomTabBarHeight } from '@react-navigation/bottom-tabs';
import { useBottomTabBarHeight } from "expo-router/js-tabs";
import { BlurView } from 'expo-blur';
import { StyleSheet } from 'react-native';

Expand Down
Loading