Sha256: 50761ce7eab5fccc6951b50610740848dc17d3428c83204c1125f2e5f2bfc05b

Contents?: true

Size: 1 KB

Versions: 6

Compression:

Stored size: 1 KB

Contents

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

import {
  selectItems,
  selectStatus,
  selectAutoRefresh,
} from './TargetingHostsSelectors';
import { getData } from './TargetingHostsActions';
import { TARGETING_HOSTS } from './TargetingHostsConsts';

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

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

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

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

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

export default WrappedTargetingHosts;

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
foreman_remote_execution-3.3.7 webpack/react_app/components/TargetingHosts/index.js
foreman_remote_execution-3.3.6 webpack/react_app/components/TargetingHosts/index.js
foreman_remote_execution-3.3.5 webpack/react_app/components/TargetingHosts/index.js
foreman_remote_execution-3.3.4 webpack/react_app/components/TargetingHosts/index.js
foreman_remote_execution-3.3.3 webpack/react_app/components/TargetingHosts/index.js
foreman_remote_execution-3.3.2 webpack/react_app/components/TargetingHosts/index.js