Sha256: 93b906e38bd5c976d9399936d44dde9d5051e285e5f60b4f204de49510205354

Contents?: true

Size: 783 Bytes

Versions: 48

Compression:

Stored size: 783 Bytes

Contents

import React, { useEffect, useRef } from 'react';

export const withRenderHandler = ({ Component }) => componentProps => (
  <Component {...componentProps} />
);

export const callOnMount = callback => WrappedComponent => componentProps => {
  callback(componentProps);

  return <WrappedComponent {...componentProps} />;
};

export const callOnPopState = callback => WrappedComponent => componentProps => {
  const didMount = useRef(false);
  const {
    history: {
      action,
      location: { search },
    },
  } = componentProps;
  useEffect(() => {
    if (action === 'POP' && didMount.current) {
      callback(componentProps);
    } else {
      didMount.current = true;
    }
  }, [search, action, componentProps]);

  return <WrappedComponent {...componentProps} />;
};

Version data entries

48 entries across 48 versions & 3 rubygems

Version Path
foreman_bootdisk-22.0.2 webpack/__mocks__/foremanReact/common/HOC.js
foreman_bootdisk-22.0.1 webpack/__mocks__/foremanReact/common/HOC.js
foreman_webhooks-4.0.0 webpack/__mocks__/foremanReact/common/HOC.js
foreman_bootdisk-22.0.0 webpack/__mocks__/foremanReact/common/HOC.js
foreman_webhooks-3.2.3 webpack/__mocks__/foremanReact/common/HOC.js
foreman_bootdisk-21.0.6 webpack/__mocks__/foremanReact/common/HOC.js
foreman_bootdisk-21.2.3 webpack/__mocks__/foremanReact/common/HOC.js
foreman_bootdisk-21.2.2 webpack/__mocks__/foremanReact/common/HOC.js
foreman_bootdisk-21.0.5 webpack/__mocks__/foremanReact/common/HOC.js
foreman_bootdisk-21.2.1 webpack/__mocks__/foremanReact/common/HOC.js
foreman_bootdisk-21.2.0 webpack/__mocks__/foremanReact/common/HOC.js
foreman_webhooks-3.2.2 webpack/__mocks__/foremanReact/common/HOC.js
foreman_bootdisk-21.1.0 webpack/__mocks__/foremanReact/common/HOC.js
foreman_webhooks-3.1.1 webpack/__mocks__/foremanReact/common/HOC.js
foreman_webhooks-3.2.1 webpack/__mocks__/foremanReact/common/HOC.js
foreman_bootdisk-19.0.9 webpack/__mocks__/foremanReact/common/HOC.js
foreman_webhooks-3.2.0 webpack/__mocks__/foremanReact/common/HOC.js
foreman_webhooks-3.1.0 webpack/__mocks__/foremanReact/common/HOC.js
foreman_bootdisk-21.0.4 webpack/__mocks__/foremanReact/common/HOC.js
foreman_bootdisk-21.0.3 webpack/__mocks__/foremanReact/common/HOC.js