Export named `React` members
ryan-roemer opened this issue · 4 comments
A lot of libraries use named exports from React. And IIRC we have to manually enumerate those. I've got a temp shim looking like this that might be a useful starting point (would be nice to automate this maybe like react-ecmascript
project does...)
/**
* es-react needs exports for the individual methods.
*
* This is a shim until things are fixed from:
* https://unpkg.com/browse/react-ecmascript@1.4.4/react.development.mjs
*/
import React from 'https://unpkg.com/es-react@16.8.60/src/react.js';
export default React;
const {
Children,
createRef,
Component,
PureComponent,
createContext,
forwardRef,
lazy,
memo,
useCallback,
useContext,
useEffect,
useImperativeHandle,
useDebugValue,
useLayoutEffect,
useMemo,
useReducer,
useRef,
useState,
Fragment,
StrictMode,
Suspense,
createElement,
cloneElement,
createFactory,
isValidElement,
version,
unstable_ConcurrentMode,
unstable_Profiler,
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
} = React;
export {
Children,
createRef,
Component,
PureComponent,
createContext,
forwardRef,
lazy,
memo,
useCallback,
useContext,
useEffect,
useImperativeHandle,
useDebugValue,
useLayoutEffect,
useMemo,
useReducer,
useRef,
useState,
Fragment,
StrictMode,
Suspense,
createElement,
cloneElement,
createFactory,
isValidElement,
version,
unstable_ConcurrentMode,
unstable_Profiler,
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
};
Just to confirm intent here, this would make it possible to do:
import React, { useState } from 'https://unpkg.com/es-react@16.8.60/src/react.js'
Which is common practice but currently not possible with this build, right?
Yep, exactly!
Ok cool, well that make sense! I'm happy for the next release to be architected like this 👍I only just noticed that 16.9.0
has been released.. so it is about time that happened (will try get round to it soon). It would be nice to automate!
Hey @ryan-roemer I have implemented this here #5. If you could confirm that this is what you were after then I can merge and publish.