-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
connected header and navbar components to redux store to get links
- Loading branch information
1 parent
aa94fd1
commit 579f9cb
Showing
4 changed files
with
60 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,35 @@ | ||
import React, { Component } from 'react'; | ||
|
||
import { connect } from 'react-redux'; | ||
|
||
class Header extends Component { | ||
render() { | ||
return ( | ||
<div className='header'> | ||
<img src='http://via.placeholder.com/50x50'/> | ||
<div className='header__links'> | ||
{ | ||
this.props.headerLinks.map((link, index) => { | ||
return ( | ||
<a className='header__link' key={index} onClick={() => console.log('trying to switch tab')}> | ||
{link.title} | ||
</a> | ||
) | ||
}) | ||
} | ||
</div> | ||
</div> | ||
) | ||
} | ||
} | ||
|
||
function mapStateToProps(state) { | ||
const{ headerLinks } = state.headerNavbar; | ||
return { | ||
headerLinks | ||
} | ||
} | ||
|
||
Header = connect(mapStateToProps)(Header); | ||
|
||
export default Header; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,32 @@ | ||
import React, { Component } from 'react'; | ||
|
||
import { connect } from 'react-redux'; | ||
|
||
class Navbar extends Component { | ||
render() { | ||
return ( | ||
<div className='navbar'> | ||
|
||
{ | ||
this.props.navbarLinks.map((link, index) => { | ||
return ( | ||
<a className='navbar__link' key={index} onClick={() => console.log('trying to switch tab')}> | ||
{link.title} | ||
</a> | ||
) | ||
}) | ||
} | ||
</div> | ||
) | ||
} | ||
} | ||
|
||
function mapStateToProps(state) { | ||
const{ navbarLinks } = state.headerNavbar; | ||
return { | ||
navbarLinks | ||
} | ||
} | ||
|
||
Navbar = connect(mapStateToProps)(Navbar); | ||
|
||
export default Navbar; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
import { combineReducers } from 'redux'; | ||
import { reducer as form } from 'redux-form'; | ||
|
||
import HeaderNavbar from './headernavbarReducer'; | ||
import headerNavbar from './headernavbarReducer'; | ||
|
||
const rootReducer = combineReducers({ | ||
form, | ||
HeaderNavbar | ||
headerNavbar | ||
}); | ||
|
||
export default rootReducer; |