Skip to content

Commit 6264acb

Browse files
author
Krit
committed
- Add router as contextTypes of Popover.react as react-router Link need router as context
- Change AppsMenu.react from stateless to React.Component to get contextTypes
1 parent e8db69b commit 6264acb

File tree

2 files changed

+32
-23
lines changed

2 files changed

+32
-23
lines changed

src/components/Popover/Popover.react.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ class ContextProxy extends React.Component {
2222
}
2323

2424
ContextProxy.childContextTypes = {
25-
history: React.PropTypes.object
25+
history: React.PropTypes.object,
26+
router: React.PropTypes.object
2627
};
2728

2829
export default class Popover extends React.Component {
@@ -93,5 +94,6 @@ export default class Popover extends React.Component {
9394
}
9495

9596
Popover.contextTypes = {
96-
history: React.PropTypes.object
97+
history: React.PropTypes.object,
98+
router: React.PropTypes.object
9799
};

src/components/Sidebar/AppsMenu.react.js

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,35 @@
88
import AppBadge from 'components/AppBadge/AppBadge.react';
99
import html from 'lib/htmlString';
1010
import { Link } from 'react-router';
11-
import React from 'react';
11+
import React from 'react';
1212
import styles from 'components/Sidebar/Sidebar.scss';
1313
import { unselectable } from 'stylesheets/base.scss';
1414

15-
let AppsMenu = ({ apps, current, height, onSelect }) => (
16-
<div style={{ height }} className={[styles.appsMenu, unselectable].join(' ')}>
17-
<div className={styles.currentApp} onClick={onSelect.bind(null, current.slug)}>
18-
{current.name}
19-
</div>
20-
<div className={styles.menuSection}>All Apps</div>
21-
{apps.map((app) => {
22-
if (app.slug === current.slug) {
23-
return null;
24-
}
25-
return (
26-
<Link to={{ pathname: html`/apps/${app.slug}/browser` }} key={app.slug} className={styles.menuRow}>
27-
{app.name}
28-
<AppBadge production={app.production} />
29-
</Link>
30-
);
31-
})}
32-
</div>
33-
);
15+
export default class AppsMenu extends React.Component {
16+
render() {
17+
const { apps, current, height, onSelect } = this.props;
18+
return (
19+
<div style={{ height }} className={[styles.appsMenu, unselectable].join(' ')}>
20+
<div className={styles.currentApp} onClick={onSelect.bind(null, current.slug)}>
21+
{current.name}
22+
</div>
23+
<div className={styles.menuSection}>All Apps</div>
24+
{apps.map((app) => {
25+
if (app.slug === current.slug) {
26+
return null;
27+
}
28+
return (
29+
<Link to={{ pathname: html`/apps/${app.slug}/browser` }} key={app.slug} className={styles.menuRow} >
30+
{app.name}
31+
<AppBadge production={app.production} />
32+
</Link>
33+
);
34+
})}
35+
</div>
36+
);
37+
}
38+
}
3439

35-
export default AppsMenu;
40+
AppsMenu.contextTypes = {
41+
router: React.PropTypes.object
42+
};

0 commit comments

Comments
 (0)