Only query once during initial render

This commit is contained in:
Chi Vinh Le
2017-04-27 17:30:43 +07:00
parent bb532b5eb2
commit 20b4c4e2d0
2 changed files with 6 additions and 1 deletions
@@ -118,7 +118,9 @@ class StreamContainer extends React.Component {
};
componentDidMount() {
this.props.data.refetch();
if (this.props.previousTab) {
this.props.data.refetch();
}
this.countPoll = setInterval(() => {
const {asset} = this.props.root;
this.getCounts({
@@ -236,6 +238,7 @@ const mapStateToProps = state => ({
assetId: state.stream.assetId,
assetUrl: state.stream.assetUrl,
activeTab: state.embed.activeTab,
previousTab: state.embed.previousTab,
});
const mapDispatchToProps = dispatch =>
@@ -2,6 +2,7 @@ import * as actions from '../constants/embed';
const initialState = {
activeTab: 'stream',
previousTab: '',
};
export default function stream(state = initialState, action) {
@@ -10,6 +11,7 @@ export default function stream(state = initialState, action) {
return {
...state,
activeTab: action.tab,
previousTab: state.activeTab,
};
default:
return state;