File size: 959 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# User State

A module for managing user state.

## Actions

Used in combination with the Redux store instance `dispatch` function, actions can be used in manipulating the current global state.

### `setCurrentUser( user: Object )`

Sets the current user by user ID.

```js
import { setCurrentUser } from 'calypso/state/current-user/actions';

dispatch( setCurrentUser( { ID: 73705554 } ) );
```

## Reducers

The included reducers add the following keys to the global state tree, under `currentUser`:

### `id`

The current user ID, or `null` if the user has not been assigned as in the case of a logged-out session.

## Selectors

Selectors are intended to assist in extracting data from the global state tree for consumption by other modules.

### `getCurrentUser( state: Object )`

Returns the current user object.

```js
import { getCurrentUser } from 'calypso/state/current-user/selectors';

const selectedSite = getCurrentUser( store.getState() );
```