Skip to content

Commit

Permalink
Use "Var" suffix for reactive variable names
Browse files Browse the repository at this point in the history
lorensr authored Oct 26, 2020
1 parent 956fbf9 commit 20ea528
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions docs/source/local-state/reactive-variables.mdx
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ Create a reactive variable with the `makeVar` method, like so:
```js
import { makeVar } from '@apollo/client';

const cartItems = makeVar([]);
const cartItemsVar = makeVar([]);
```

This code creates a reactive variable with an empty array as its initial value.
@@ -26,28 +26,28 @@ This code creates a reactive variable with an empty array as its initial value.
To read the value of your reactive variable, call the function returned by `makeVar` with zero arguments:

```js
const cartItems = makeVar([]);
const cartItemsVar = makeVar([]);

// Output: []
console.log(cartItems());
console.log(cartItemsVar());
```

## Modifying

To modify the value of your reactive variable, call the function returned by `makeVar` with one argument (the variable's new value):

```js
const cartItems = makeVar([]);
const cartItemsVar = makeVar([]);

cartItems([100, 101, 102]);
cartItemsVar([100, 101, 102]);

// Output: [100, 101, 102]
console.log(cartItems());
console.log(cartItemsVar());

cartItems([456]);
cartItemsVar([456]);

// Output: [456]
console.log(cartItems());
console.log(cartItemsVar());
```

## Reacting

0 comments on commit 20ea528

Please sign in to comment.