-
-
Save calvinfroedge/98258fb9e824f9f7ea6803a222d5f2bb to your computer and use it in GitHub Desktop.
React / Redux App Wrapper
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
import React from 'react' | |
import { connect } from 'react-redux' | |
import { AppHeader } from 'react-redux-app-header' | |
class Wrapper extends React.Component { | |
render(){ | |
let { props } = this; | |
const authenticated = props.auth.token; | |
let authClass = (authenticated ? 'auth' : 'noauth'); | |
return <div className={authClass}> | |
<AppHeader {...props.header} /> | |
{ this.props.children } | |
</div> | |
} | |
} | |
Wrapper.defaultProps = { | |
header: {} | |
} | |
export default connect((state)=>{ | |
const {auth} = state; | |
return {auth}; | |
})(Wrapper); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment