File size: 1,177 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
# DomainManagementData

A component that fetches data based on given props and then passes them to its children.

## Usage

Pass a component as a child of `<DomainManagementData />`. `DomainManagementData` will pass data to the given component, which is mounted as a child.
It will handle the data itself thus helping us to decouple concerns: i.e. fetching and displaying data. This pattern is also called [container components](https://medium.com/@learnreact/container-components-c0e67432e005).

```js
import DomainManagementData from 'calypso/components/data/domain-management';
import MyChildComponent from 'calypso/components/my-child-component';

// initialize rest of the variables

const MyComponent = () => (
	<DomainManagementData component={ MyChildComponent } context={ context } needsDomains />
);

export default MyComponent;
```

Currently we use Redux. Props for loading data:

- `needsDomains` - Loads domain for currently selected site
- `needsPlans` - Loads plans for given site
- `needsProductsList` - Loads products list

The child component should receive processed props defined in `getStateFromStores()`. It's updated whenever the data it needs changes.