PHP 8.2.30
Preview: with-no-ssr.js Size: 944 B
//proc/thread-self/root/home/byroehnu/.trash/node_modules11/adminjs/lib/frontend/hoc/with-no-ssr.js

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

/**
 * A higher-order component that prevents a component from rendering server-side
 *
 * @template P - The props object of the wrapped component
 * @param {React.ComponentType<P>} Component - The component to be wrapped
 * @returns {React.FC<P>} A new component that renders the given component client-side only
 */
// eslint-disable-next-line max-len
const withNoSSR = Component => props => {
  const [isClient, setIsClient] = useState(false);

  /**
   * Sets isClient to true when the component is mounted on the client side
   */
  useEffect(() => {
    setIsClient(true);
  }, []);

  // Renders nothing if the component is not mounted on the client side
  if (!isClient) return null;

  // Renders the wrapped component with the given props if it's mounted on the client side
  return /*#__PURE__*/React.createElement(Component, props);
};
export { withNoSSR as default, withNoSSR };

Directory Contents

Dirs: 0 × Files: 4

Name Size Perms Modified Actions
1.35 KB lrw-r--r-- 2026-02-28 00:29:22
Edit Download
104 B lrw-r--r-- 2026-02-28 00:31:44
Edit Download
944 B lrw-r--r-- 2026-02-28 00:31:52
Edit Download
1.06 KB lrw-r--r-- 2026-02-28 00:31:52
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).