Sha256: 0cf16a1fdb2f9bf582c94a773b4261c84d536a0764322bcdd6a66052142a93ba

Contents?: true

Size: 952 Bytes

Versions: 9

Compression:

Stored size: 952 Bytes

Contents

import React, { useEffect, useState } from 'react';
import { useSelector, useDispatch } from 'react-redux';
import { stopInterval } from 'foremanReact/redux/middlewares/IntervalMiddleware';
import Rounds from './Rounds';

import {
    selectItems,
    selectStatus,
    selectAutoRefresh,
} from './RoundsSelectors';
import { getData } from './RoundsActions';
import { ROUNDS } from './RoundsConsts';

const WrappedRounds = () => {
  const dispatch = useDispatch();
  const autoRefresh = useSelector(selectAutoRefresh);
  const items = useSelector(selectItems);
  const status = useSelector(selectStatus);

  useEffect(() => {
    dispatch(getData());

    return () => {
      dispatch(stopInterval(ROUNDS));
    };
  }, [dispatch]);

  useEffect(() => {
    if (autoRefresh === 'false') {
      dispatch(stopInterval(ROUNDS));
    }
  }, [autoRefresh, dispatch]);

  return <Rounds status={status} items={items} />;
};

export default WrappedRounds;

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
foreman_patch-1.2.1 webpack/components/Rounds/index.js
foreman_patch-1.2.0 webpack/components/Rounds/index.js
foreman_patch-1.2.0.alpha1 webpack/components/Rounds/index.js
foreman_patch-1.1.6.alpha5 webpack/components/Rounds/index.js
foreman_patch-1.1.6.alpha4 webpack/components/Rounds/index.js
foreman_patch-1.1.5 webpack/components/Rounds/index.js
foreman_patch-1.1.4 webpack/components/Rounds/index.js
foreman_patch-1.1.3 webpack/components/Rounds/index.js
foreman_patch-1.1.1 webpack/components/Rounds/index.js