Skip to content

Instantly share code, notes, and snippets.

@calvinfroedge
Created May 1, 2016 21:34
Show Gist options
  • Save calvinfroedge/98258fb9e824f9f7ea6803a222d5f2bb to your computer and use it in GitHub Desktop.
Save calvinfroedge/98258fb9e824f9f7ea6803a222d5f2bb to your computer and use it in GitHub Desktop.
React / Redux App Wrapper
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