How to use the react-is.Fragment function in react-is

To help you get started, we’ve selected a few react-is 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 milesj / rut / packages / rut / src / internals / react.ts View on Github external
const typeOf = type.$$typeof;

  if (ReactIs.isContextConsumer(type) || typeOf === ReactIs.ContextConsumer) {
    return `${getContextName(type)}.Consumer`;
  }

  if (ReactIs.isContextProvider(type) || typeOf === ReactIs.ContextProvider) {
    return `${getContextName(type)}.Provider`;
  }

  if (ReactIs.isForwardRef(type) || typeOf === ReactIs.ForwardRef) {
    return 'ForwardRef'; // We lose the component name
  }

  if (ReactIs.isFragment(type) || typeOf === ReactIs.Fragment) {
    return 'Fragment';
  }

  if (ReactIs.isLazy(type) || typeOf === ReactIs.Lazy) {
    return 'Lazy';
  }

  if (ReactIs.isMemo(type)) {
    return getTypeName(type.type);
  } else if (typeOf === ReactIs.Memo) {
    return `Memo(${getTypeName(type.type)})`;
  }

  if (ReactIs.isProfiler(type) || typeOf === ReactIs.Profiler) {
    return `Profiler(${type.props!.id})`;
  }
github FormidableLabs / react-ssr-prepass / src / symbols.js View on Github external
| 'react.element' /* 0xeac7 | Symbol(react.element) */
  | 'react.portal' /* 0xeaca | Symbol(react.portal) */
  | 'react.fragment' /* 0xeacb | Symbol(react.fragment) */
  | 'react.strict_mode' /* 0xeacc | Symbol(react.strict_mode) */
  | 'react.profiler' /* 0xead2 | Symbol(react.profiler) */
  | 'react.provider' /* 0xeacd | Symbol(react.provider) */
  | 'react.context' /* 0xeace | Symbol(react.context) */
  | 'react.concurrent_mode' /* 0xeacf | Symbol(react.concurrent_mode) */
  | 'react.forward_ref' /* 0xead0 | Symbol(react.forward_ref) */
  | 'react.suspense' /* 0xead1 | Symbol(react.suspense) */
  | 'react.memo' /* 0xead3 | Symbol(react.memo) */
  | 'react.lazy' /* 0xead4 | Symbol(react.lazy) */

export const REACT_ELEMENT_TYPE: 'react.element' = is.Element
export const REACT_PORTAL_TYPE: 'react.portal' = is.Portal
export const REACT_FRAGMENT_TYPE: 'react.fragment' = is.Fragment
export const REACT_STRICT_MODE_TYPE: 'react.strict_mode' = is.StrictMode
export const REACT_PROFILER_TYPE: 'react.profiler' = is.Profiler
export const REACT_PROVIDER_TYPE: 'react.provider' = is.ContextProvider
export const REACT_CONTEXT_TYPE: 'react.context' = is.ContextConsumer
export const REACT_CONCURRENT_MODE_TYPE: 'react.concurrent_mode' =
  is.ConcurrentMode
export const REACT_FORWARD_REF_TYPE: 'react.forward_ref' = is.ForwardRef
export const REACT_SUSPENSE_TYPE: 'react.suspense' = is.Suspense
export const REACT_MEMO_TYPE: 'react.memo' = is.Memo
export const REACT_LAZY_TYPE: 'react.lazy' = is.Lazy
github FormidableLabs / react-ssr-prepass / src / __tests__ / element.js View on Github external
typeOf({
        $$typeof: is.Portal
      })
    ).toBe(REACT_PORTAL_TYPE)

    expect(
      typeOf({
        $$typeof: is.Element,
        type: is.ConcurrentMode
      })
    ).toBe(REACT_CONCURRENT_MODE_TYPE)

    expect(
      typeOf({
        $$typeof: is.Element,
        type: is.Fragment
      })
    ).toBe(REACT_FRAGMENT_TYPE)

    expect(
      typeOf({
        $$typeof: is.Element,
        type: is.Profiler
      })
    ).toBe(REACT_PROFILER_TYPE)

    expect(
      typeOf({
        $$typeof: is.Element,
        type: is.StrictMode
      })
    ).toBe(REACT_STRICT_MODE_TYPE)
github propertybase / react-lds / src / components / Button / ButtonGroups / ButtonGroup.js View on Github external
const wrapLi = (parentEl, i) => {
    const isFragment = ReactIs.typeOf(parentEl) === ReactIs.Fragment;

    const toLi = (childEl, index) => (
      <li>
        {childEl}
      </li>
    );

    return isFragment
      ? React.Children.map(parentEl.props.children, (child, j) =&gt; toLi(child, `${i}-${j}`))
      : toLi(parentEl, i);
  };