Skip to content

Commit

Permalink
[Tests] react-compat: add some more react exports
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Feb 9, 2019
1 parent b4efaad commit f5798eb
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions packages/enzyme-test-suite/test/_helpers/react-compat.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

import { is } from './version';

const { createFactory } = require('react');

let createClass;
let renderToString;
let createPortal;
Expand All @@ -21,6 +23,16 @@ let PureComponent;
let Suspense;
let lazy;
let memo;
let useCallback;
let useContext;
let useDebugValue;
let useEffect;
let useImperativeHandle;
let useLayoutEffect;
let useMemo;
let useReducer;
let useRef;
let useState;

if (is('>=15.5 || ^16.0.0-alpha || ^16.3.0-alpha')) {
// eslint-disable-next-line import/no-extraneous-dependencies
Expand Down Expand Up @@ -92,8 +104,35 @@ if (is('^16.6.0-0')) {
memo = null;
}

if (is('^16.8.0-0')) {
({
useCallback,
useContext,
useDebugValue,
useEffect,
useImperativeHandle,
useLayoutEffect,
useMemo,
useReducer,
useRef,
useState,
} = require('react'));
} else {
useCallback = null;
useContext = null;
useDebugValue = null;
useEffect = null;
useImperativeHandle = null;
useLayoutEffect = null;
useMemo = null;
useReducer = null;
useRef = null;
useState = null;
}

export {
createClass,
createFactory,
renderToString,
createPortal,
createContext,
Expand All @@ -108,4 +147,14 @@ export {
Suspense,
lazy,
memo,
useCallback,
useContext,
useDebugValue,
useEffect,
useImperativeHandle,
useLayoutEffect,
useMemo,
useReducer,
useRef,
useState,
};

0 comments on commit f5798eb

Please sign in to comment.