@configdirector/react-native-sdk 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -10,15 +10,94 @@ Install from NPM:
10
10
  npm install --save @configdirector/react-native-sdk
11
11
  ```
12
12
 
13
+ ### 2. Initialize the provider using your client SDK key
13
14
 
14
- ## Usage
15
+ ```tsx
16
+ import { View } from "react-native";
17
+ import AwesomeApp from "./AwesomeApp";
18
+ import { ConfigDirectorProvider } from "@configdirector/react-native-sdk";
19
+
20
+ export default function App() {
21
+ return (
22
+ <ConfigDirectorProvider
23
+ sdkKey={"YOUR-CLIENT-SDK-KEY"}
24
+ appName="MyAwesomeApp"
25
+ appVersion="1.0.0">
26
+ <View>
27
+ <AwesomeApp />
28
+ </View>
29
+ </ConfigDirectorProvider>
30
+ );
31
+ }
32
+ ```
15
33
 
34
+ ### 3. Retrieve config values
35
+
36
+ Retrieve a config value with the `useConfigValue` hook:
16
37
 
17
38
  ```tsx
18
- import { createClient } from "@configdirector/react-native-sdk";
39
+ import { useConfigValue } from "@configdirector/react-native-sdk";
40
+
41
+ function MyComponent() {
42
+ const { value } = useConfigValue<string>("my-config", "default value");
19
43
 
44
+ return <p>My config value: {value}</p>;
45
+ }
46
+
47
+ export default MyComponent;
20
48
  ```
21
49
 
50
+ You can also determine if the client is still initializing, so rather than transition from the default value to the evaluated value, you can show a loading state until the client is ready and config values are evaluated:
51
+
52
+ ```tsx
53
+ import { useConfigValue } from "@configdirector/react-native-sdk";
54
+
55
+ function MyComponent() {
56
+ const { value, loading } = useConfigValue<string>(
57
+ "my-config",
58
+ "default value",
59
+ );
60
+
61
+ if (loading) {
62
+ return <p>Loading...</p>;
63
+ } else {
64
+ return <p>My config value: {value}</p>;
65
+ }
66
+ }
67
+
68
+ export default MyComponent;
69
+ ```
70
+
71
+ ### 4. Updating the user context
72
+
73
+ Update the user context with the `useConfigDirectorContext` hook:
74
+
75
+ ```tsx
76
+ import {
77
+ useConfigValue,
78
+ useConfigDirectorContext,
79
+ } from "@configdirector/react-native-sdk";
80
+
81
+ function MyComponent() {
82
+ const { value: myConfigValue } = useConfigValue<string>(
83
+ "my-config",
84
+ "default value",
85
+ );
86
+ const { updateContext } = useConfigDirectorContext();
87
+
88
+ useEffect(() => {
89
+ updateContext({
90
+ id: "54321",
91
+ name: "Another User",
92
+ traits: { customProperty: "customValue" },
93
+ });
94
+ }, []);
95
+
96
+ return <p>My config value: {myConfigValue}</p>;
97
+ }
98
+
99
+ export default MyComponent;
100
+ ```
22
101
 
23
102
  ## Requirements
24
103
 
@@ -37,3 +116,7 @@ Expo SDK 48 (RN 0.71) or later is required.
37
116
  ## License
38
117
 
39
118
  MIT
119
+
120
+ ## Getting Help
121
+
122
+ Reach out to us via https://www.configdirector.com/support
@@ -1377,7 +1377,7 @@ const createClient = (clientSdkKey, clientOptions) => {
1377
1377
  const logger = (_clientOptions$logger = clientOptions === null || clientOptions === void 0 ? void 0 : clientOptions.logger) !== null && _clientOptions$logger !== void 0 ? _clientOptions$logger : createConsoleLogger("warn");
1378
1378
  return new DefaultConfigDirectorClient(new ReactNativeTelemetryClient(clientSdkKey, (clientOptions === null || clientOptions === void 0 || (_clientOptions$connec = clientOptions.connection) === null || _clientOptions$connec === void 0 ? void 0 : _clientOptions$connec.url) ? urlFactory(clientOptions.connection.url) : CLIENT_BASE_URL, logger, urlFactory), clientSdkKey, {
1379
1379
  sdkName: "react-native-sdk",
1380
- sdkVersion: "0.1.0"
1380
+ sdkVersion: "0.1.1"
1381
1381
  }, {
1382
1382
  ...clientOptions,
1383
1383
  logger
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@configdirector/react-native-sdk",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "React Native client SDK for ConfigDirector. ConfigDirector is a remote configuration and feature flag service.",
5
5
  "license": "MIT",
6
6
  "author": "ConfigDirector",