Skip to content

Commit

Permalink
Add documentation for component prop
Browse files Browse the repository at this point in the history
  • Loading branch information
jdlehman committed Nov 6, 2015
1 parent 4543f17 commit 56ecbb2
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,54 @@ var A = React.createClass({
});
```

### Component Property

You may specify an optional `component` property on the `MediaQuery` that indicates what component to wrap children with. Any additional props defined on the `MediaQuery` will be passed through to this "wrapper" component. If the `component` property is not defined and the `MediaQuery` has more than 1 child, a `div` will be used as the "wrapper" component by default. However, if the `component` prop is not defined and there is only 1 child, that child will be rendered alone without a component wrapping it.

**Specifying Wrapper Component**

```jsx
<MediaQuery minDeviceWidth={700} component="ul">
<li>Item 1</li>
<li>Item 2</li>
</MediaQuery>

// renders the following when the media query condition is met

<ul>
<li>Item 1</li>
<li>Item 2</li>
</ul>
```

**Unwrapped Component**

```jsx
<MediaQuery minDeviceWidth={700}>
<div>Unwrapped component</div>
</MediaQuery>

// renders the following when the media query condition is met

<div>Unwrapped component</div>
```

**Default div Wrapper Component**

```jsx
<MediaQuery minDeviceWidth={1200} className="some-class">
<div>Wrapped</div>
<div>Content</div>
</MediaQuery>

// renders the following when the media query condition is met

<div className="some-class">
<div>Wrapped</div>
<div>Content</div>
</div>
```

### Server rendering

Server rendering can be done by passing static values through the `values` property.
Expand Down

0 comments on commit 56ecbb2

Please sign in to comment.