Skip to content

Commit 71879ac

Browse files
committed
Create links from array
1 parent 9d71d91 commit 71879ac

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

app/components/Menu/Menu.js

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,14 @@ class Menu extends React.Component{
88
this.handleView = this.handleView.bind(this);
99
this.toggleNav = this.toggleNav.bind(this);
1010
this.handleLink = this.handleLink.bind(this);
11+
this.createLink = this.createLink.bind(this);
1112
this.state = {
12-
toggleNav: ''
13+
toggleNav: '',
14+
links: [
15+
[ '/', 'Home'],
16+
['/client', 'Client'],
17+
['/area', 'Area']
18+
]
1319
};
1420
}
1521

@@ -27,6 +33,18 @@ class Menu extends React.Component{
2733
this.setState({toggleNav: ''});
2834
}
2935

36+
createLink() {
37+
return this.state.links.map((link, index) => (
38+
<Link to={link[0]}
39+
key={index}
40+
className="nav-item is-tab"
41+
onlyActiveOnIndex={true}
42+
activeClassName="is-active"
43+
onClick={this.handleLink}>{link[1]}
44+
</Link>
45+
));
46+
}
47+
3048
handleView() {
3149
return (
3250
<nav className="nav has-shadow" id="top">
@@ -40,22 +58,7 @@ class Menu extends React.Component{
4058
<span></span>
4159
</span>
4260
<div className={ `nav-right nav-menu ${this.state.toggleNav}` }>
43-
<Link to="/"
44-
className="nav-item is-tab"
45-
onlyActiveOnIndex={true}
46-
activeClassName="is-active"
47-
onClick={this.handleLink}>Home
48-
</Link>
49-
<Link to="/client"
50-
className="nav-item is-tab"
51-
activeClassName="is-active"
52-
onClick={this.handleLink}>Client
53-
</Link>
54-
<Link to="/area"
55-
className="nav-item is-tab"
56-
activeClassName="is-active"
57-
onClick={this.handleLink}>Area
58-
</Link>
61+
{this.createLink()}
5962
<span className="nav-item">
6063
<a className="button" onClick={this.handleLogout}>Logout</a>
6164
</span>

0 commit comments

Comments
 (0)