1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-09-05 17:53:12 +02:00

fix: update docs

This commit is contained in:
Fredrik Oseberg 2021-08-17 14:39:02 +02:00
parent 8ee317439a
commit ea312e574e
3 changed files with 29 additions and 14 deletions

View File

@ -8,15 +8,15 @@ title: React proxy SDK
# Installation
```
npm install @unleash/unleash-proxy-react
npm install @unleash/proxy-client-react
// or
yarn add @unleash/unleash-proxy-react
yarn add @unleash/proxy-client-react
```
Import the provider like this in your entrypoint file (typically index.js/ts):
```
import FlagProvider from '@unleash/unleash-proxy-react';
import FlagProvider from '@unleash/proxy-client-react';
const config = {
url: 'https://HOSTNAME/api/proxy',
@ -39,7 +39,7 @@ ReactDOM.render(
To check if a feature is enabled:
```
import { useFlag } from '@unleash/unleash-proxy-react';
import { useFlag } from '@unleash/proxy-client-react';
const TestComponent = () => {
const enabled = useFlag('travel.landing');
@ -56,7 +56,7 @@ export default TestComponent;
To check variants:
```
import { useVariant } from '@unleash/unleash-proxy-react';
import { useVariant } from '@unleash/proxy-client-react';
const TestComponent = () => {
const variant = useVariant('travel.landing');
@ -77,7 +77,7 @@ export default TestComponent;
Follow the following steps in order to update the unleash context:
```
import { useUnleashContext, useFlag } from '@unleash/unleash-proxy-react'
import { useUnleashContext, useFlag } from '@unleash/proxy-client-react'
const MyComponent = ({ userId }) => {
const variant = useFlag("my-toggle");

View File

@ -25,14 +25,16 @@ All our SDKs perform local evaluation of feature toggles, which means that they
## Unleash Context
Since the SDKs perform local evaluation, some of the parameters needed for evaluation must be supplied through the Unleash Context. The unleash context allows you to pass in userIds, sessionIds or other relevant information that is needed in order to perform the evaluation. If, for example, you want to enable a feature for a set of specific userIds, you would need to provide the userIds in the unleash context in order for the evaluation to enable the feature.
Since the SDKs perform local evaluation, some of the parameters needed for evaluation must be supplied through the Unleash Context. The unleash context allows you to pass in userIds, sessionIds or other relevant information that is needed in order to perform the evaluation. If, for example, you want to enable a feature for a set of specific userIds, you would need to provide the current userId in the unleash context in order for the evaluation to enable the feature.
[You can read more about the unleash context here.](./unleash_context)
## API architecture
The unleash API is split into two. One API is for the clients connecting unleash and is located under the path /api/client, and provides access to retrieving saved feature toggle configurations, metrics and registering the application.
The Unleash API is split into two. One API is for the clients connecting unleash and is located under the path /api/client, and provides access to retrieving saved feature toggle configurations, metrics and registering the application.
The second API is the admin API, which is utilised in order to control any CRUD aspect of unleash resources. The split ensures a second layer of security that ensures that in the case you should loose your client api key, attackers will only have read-only access to your feature toggle configurations.
This ensures that we can have different data responses for the client API endpoints which will include less metadata, and be cached more heavily - optimising the SDK endpoints for best performance.
[Read more about unleash API here](../api)

View File

@ -196,15 +196,28 @@ unleash.on('synchronized', () => {
## I want to run Unleash locally
### Run Unleash with docker-compose
### Run Unleash with Docker
The easiest way to run unleash locally is using [docker](https://www.docker.com/) and [docker-compose](https://docs.docker.com/compose/).
The easiest way to run unleash locally is using [docker](https://www.docker.com/).
1. Clone the [unleash-docker](https://github.com/Unleash/unleash-docker) repository.
2. Run `docker-compose build` in repository root folder.
3. Run `docker-compose up` in repository root folder.
1. Create a network by running `docker network create unleash`
2. Start a postgres database:
Unleash should now be available on `http://localhost:4242`
```sh
docker run -e POSTGRES_PASSWORD=some_password \
-e POSTGRES_USER=unleash_user -e POSTGRES_DB=unleash \
--network unleash --name postgres postgres
```
3. Start Unleash via docker:
```sh
docker run -p 4242:4242 \
-e DATABASE_HOST=postgres -e DATABASE_NAME=unleash \
-e DATABASE_USERNAME=unleash_user -e DATABASE_PASSWORD=some_password \
-e DATABASE_SSL=false \
--network unleash unleashorg/unleash-server
```
[Click here to see all options to get started locally.](deploy/getting-started.md)