Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 5a9c064

Browse files
committed
Update README
1 parent a77cffc commit 5a9c064

File tree

1 file changed

+25
-7
lines changed
  • packages/js-web-sdk/packages/react-sdk

1 file changed

+25
-7
lines changed

packages/js-web-sdk/packages/react-sdk/README.md

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
Use Optimizely Feature Flags and AB Tests easily in React with a library of pre-built components.
44

5+
### Features
6+
7+
- Automatic datafile downloading and caching (through LocalStorage)
8+
- User ID + Attributes memoization
9+
- Render blocking until datafile is ready via an easy to use React API
10+
- Optimizely Timeout - only block rendering up to X ms
11+
- Event queuing for `track`, allows `track` calls to happen before datafile is downloaded
12+
- Library of React components to use with Feature Flags and AB Tests
13+
514
### Compatibility
615

716
`React 15.x +`
@@ -19,12 +28,16 @@ import optimizelySDK from '@optimizely/js-web-sdk'
1928

2029
const optimizely = optimizelySDK.createInstance({
2130
sdkKey: 'your-optimizely-sdk-key',
22-
userId: window.userId,
2331
})
2432

2533
class App extends React.Component {
2634
render() {
27-
<OptimizelyProvider optimizely={optimizely} timeout={500}>
35+
<OptimizelyProvider
36+
optimizely={optimizely}
37+
timeout={500}
38+
userId={window.userId}
39+
userAttributes={{ plan_type: 'bronze' }}
40+
>
2841
<OptimizelyExperiment experiment="ab-test">
2942
{(variation) => (
3043
<p>got variation {variation}</p>
@@ -62,7 +75,9 @@ This is required at the root level and leverages React’s `Context` API to allo
6275

6376
*props*
6477
* `optimizely : OptimizelySDK` instance of the OptimizelySDK from `@optimizely/js-web-sdk`
65-
* `timeout : Number` the amount for OptimizelyExperiment and OptimizelyFeature components to render `null` before resolving
78+
* `userId : String` userId to be passed to the SDK for every Feature Flag / AB Test / `track` call
79+
* `userAttributes : Object` (optional) userAttributes passed for every Feature Flag / AB Test / `track` call
80+
* `timeout : Number` (optional) the amount for OptimizelyExperiment and OptimizelyFeature components to render `null` before resolving
6681

6782
### Loading the datafile synchronously
6883

@@ -74,14 +89,13 @@ import { OptimizelyProvider } from '@optimizely/react-sdk'
7489
import optimizelySDK from '@optimizely/js-web-sdk'
7590

7691
const optimizely = optimizelySDK.createInstance({
77-
userId: window.userId,
7892
datafile: window.datafile,
7993
})
8094

8195
class App extends React.Component {
8296
render() {
8397
return (
84-
<OptimizelyProvider optimizely={optimizely}>
98+
<OptimizelyProvider optimizely={optimizely} userId={window.userId}>
8599
<App />
86100
</OptimizelyProvider>
87101
)
@@ -100,14 +114,18 @@ import { OptimizelyProvider } from '@optimizely/react-sdk'
100114
import optimizelySDK from '@optimizely/js-web-sdk'
101115

102116
const optimizely = optimizelySDK.createInstance({
103-
userId: window.userId,
104117
SDKKey: 'your-optimizely-sdk-key', // Optimizely environment key
105118
})
106119

107120
class App extends React.Component {
108121
render() {
109122
return (
110-
<OptimizelyProvider optimizely={optimizely} timeout={200}>
123+
<OptimizelyProvider
124+
optimizely={optimizely}
125+
timeout={500}
126+
userId={window.userId}
127+
userAttributes={{ plan_type: 'bronze' }}
128+
>
111129
<App />
112130
</OptimizelyProvider>
113131
)

0 commit comments

Comments
 (0)