Skip to content

Instantly share code, notes, and snippets.

@Tauka
Last active April 16, 2017 00:09
Show Gist options
  • Select an option

  • Save Tauka/326a14b155fed2888cdf1195341c0388 to your computer and use it in GitHub Desktop.

Select an option

Save Tauka/326a14b155fed2888cdf1195341c0388 to your computer and use it in GitHub Desktop.
import React from "react";
import { connect } from "react-redux";
import { bindActionCreators } from "redux";
import * as actions from "./actions.js";
@connect((store) => {
return {
someStore: store.someStore,
};
},
(dispatch) => {
return {
actions: bindActionCreators(actions, dispatch)
}
})
export default class SomeComponent extends React.Component {
componentWillMount() {
this.props.actions.typicalAction();
}
render() {
let condRender = null;
if (this.props.someStore.actionPending) {
condRender = <div> LOADING </div>;
} else if (this.props.someStore.actionSuccess) {
condRender = <div> MAIN CONTENT </div>;
} else if (this.props.someStore.actionFail) {
condRender = <div> ERROR </div>;
}
return (
condRender
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment