Skip to content

Commit 1dcd3d4

Browse files
chore: update readme
1 parent 3ce1334 commit 1dcd3d4

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ npm install @unleash/proxy-client-react
99
// or
1010
yarn add @unleash/proxy-client-react
1111
```
12+
# Upgrade path from v1 -> v2
13+
If you were previously using the built in Async storage used in the unleash-proxy-client-js, this no longer comes bundled with the library. You will need to install the storage adapter for your preferred storage solution. Otherwise there are no breaking changes.
1214

1315
# Initialization
1416

@@ -189,8 +191,33 @@ const MyComponent = ({ userId }) => {
189191

190192
```
191193

194+
## Use unleash client directly
195+
196+
```jsx
197+
import { useUnleashContext, useUnleashClient } from '@unleash/proxy-client-react'
198+
199+
const MyComponent = ({ userId }) => {
200+
const client = useUnleashClient();
201+
202+
const updateContext = useUnleashContext();
203+
204+
const login = () => {
205+
// login user
206+
if (client.isEnabled("new-onboarding")) {
207+
// Send user to new onboarding flow
208+
} else (
209+
// send user to old onboarding flow
210+
)
211+
}
212+
213+
return <LoginForm login={login}/>
214+
}
215+
```
216+
192217
## React Native
193218

219+
IMPORTANT: This no longer comes included in the unleash-proxy-client-js library. You will need to install the storage adapter for your preferred storage solution.
220+
194221
Because React Native doesn't run in a web browser, it doesn't have access to the `localStorage` API. Instead, you need to tell Unleash to use your specific storage provider. The most common storage provider for React Native is [AsyncStorage](https://github.com/react-native-async-storage/async-storage).
195222
To configure it, add the following property to your configuration object:
196223

0 commit comments

Comments
 (0)