Skip to content

Instantly share code, notes, and snippets.

@harrisrobin
Created March 2, 2016 16:06
Show Gist options
  • Save harrisrobin/229180d833f825143cfa to your computer and use it in GitHub Desktop.
Save harrisrobin/229180d833f825143cfa to your computer and use it in GitHub Desktop.
import React, { PropTypes } from 'react';
import {connect} from 'react-redux';
// import { Link } from 'react-router'
import styles from './HomeView.scss';
import URI from '../../utils/URL';
import { getIndustries } from '../../redux/modules/industries';
import { getPosConnectors } from '../../redux/modules/posConnectors';
// Component
import Home from '../../components/Home';
export class HomeView extends React.Component {
static propTypes = {
industries: PropTypes.array.isRequired,
getIndustries: PropTypes.func.isRequired,
posConnectors: PropTypes.array.isRequired,
getPosConnectors: PropTypes.func.isRequired
};
constructor (props) {
super(props);
}
// Define a context to pass theme through entire component tree without using props.
// https://facebook.github.io/react/docs/context.html
getChildContext = () => {
return {theme: URI.buildClassesFromPaths()};
};
componentDidMount () {
Promise.all([
this.props.getIndustries(),
this.props.getPosConnectors()
]).then(() => {
console.log('done');
});
}
render () {
return (
<div className={styles['wrapper']}>
<Home industries={this.props.industries}/>
</div>
);
}
}
HomeView.childContextTypes = {
theme: React.PropTypes.string
};
// We define mapStateToProps where we'd normally use
// the @connect decorator so the data requirements are clear upfront, but then
// export the decorated component after the main class definition so
// the component can be tested w/ and w/o being connected.
// See: http://rackt.github.io/redux/docs/recipes/WritingTests.html
const mapStateToProps = (state) => ({
industries: state.industries,
posConnectors: state.posConnectors
});
export default connect(mapStateToProps, {
getIndustries,
getPosConnectors
})(HomeView);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment