How to use the @remirror/react-utils.isReactFragment function in @remirror/react-utils

To help you get started, we’ve selected a few @remirror/react-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ifiokjr / remirror / @remirror / core-extensions / src / extensions / ssr-helpers / ssr-helpers-utils.ts View on Github external
export const cloneSSRElement = (
  element: JSX.Element,
  transformChildElements: (
    children: JSX.Element | JSX.Element[],
    childrenProps: PlainObject,
  ) => JSX.Element | JSX.Element[],
) => {
  if (!isReactFragment(element)) {
    throw new Error('Invalid element passed. The top level element must be a fragment');
  }

  const { children } = getElementProps(element);
  const childrenProps = getElementProps(children);

  return cloneElement(element, {}, transformChildElements(children, childrenProps));
};
github ifiokjr / remirror / @remirror / core-extensions / src / extensions / ssr-helpers / utils.ts View on Github external
export const cloneSSRElement = (
  element: JSX.Element,
  transformChildElements: (
    children: JSX.Element | JSX.Element[],
    childrenProps: PlainObject,
  ) => JSX.Element | JSX.Element[],
) => {
  if (!isReactFragment(element)) {
    throw new Error('Invalid element passed. The top level element must be a fragment');
  }

  const { children } = getElementProps(element);
  const childrenProps = getElementProps(children);

  return cloneElement(element, {}, transformChildElements(children, childrenProps));
};
github ifiokjr / remirror / @remirror / react / src / components / remirror-manager.tsx View on Github external
const resolvedChildren = Children.toArray(children).reduce((acc: ReactNode[], child: ReactNode) => {
      if (isReactFragment(child)) {
        return [...acc, ...Children.toArray(child.props.children)];
      } else {
        return [...acc, child];
      }
    }, []);