|
1 | | -import { CLIENT_SIDE_SDK_KEY } from '@env'; |
2 | | -import React, { useEffect, useState } from 'react'; |
3 | | -import { StyleSheet, Text, View } from 'react-native'; |
| 1 | +import { MOBILE_KEY } from '@env'; |
4 | 2 |
|
5 | | -import { init, type LDClientImpl } from '@launchdarkly/react-native-client-sdk'; |
| 3 | +import { LDProvider, ReactNativeLDClient } from '@launchdarkly/react-native-client-sdk'; |
6 | 4 |
|
7 | | -const context = { kind: 'user', key: 'test-user-1' }; |
8 | | - |
9 | | -export default function App() { |
10 | | - const [ldc, setLdc] = useState<LDClientImpl>(); |
11 | | - const [flag, setFlag] = useState<boolean>(false); |
| 5 | +import Welcome from './src/welcome'; |
12 | 6 |
|
13 | | - useEffect(() => { |
14 | | - init(CLIENT_SIDE_SDK_KEY, context) |
15 | | - .then((c) => { |
16 | | - setLdc(c); |
17 | | - }) |
18 | | - .catch((e) => console.log(e)); |
19 | | - }, []); |
20 | | - |
21 | | - useEffect(() => { |
22 | | - const f = ldc?.boolVariation('dev-test-flag', false); |
23 | | - setFlag(f ?? false); |
24 | | - }, [ldc]); |
| 7 | +const featureClient = new ReactNativeLDClient(MOBILE_KEY); |
| 8 | +const context = { kind: 'user', key: 'test-user-1' }; |
25 | 9 |
|
| 10 | +const App = () => { |
26 | 11 | return ( |
27 | | - <View style={styles.container}> |
28 | | - <Text>{flag ? <>devTestFlag: {`${flag}`}</> : <>loading...</>}</Text> |
29 | | - </View> |
| 12 | + <LDProvider client={featureClient} context={context}> |
| 13 | + <Welcome /> |
| 14 | + </LDProvider> |
30 | 15 | ); |
31 | | -} |
| 16 | +}; |
32 | 17 |
|
33 | | -const styles = StyleSheet.create({ |
34 | | - container: { |
35 | | - flex: 1, |
36 | | - alignItems: 'center', |
37 | | - justifyContent: 'center', |
38 | | - }, |
39 | | - box: { |
40 | | - width: 60, |
41 | | - height: 60, |
42 | | - marginVertical: 20, |
43 | | - }, |
44 | | -}); |
| 18 | +export default App; |
0 commit comments