Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export named React members #4

Closed
ryan-roemer opened this issue Sep 6, 2019 · 4 comments · Fixed by #6
Closed

Export named React members #4

ryan-roemer opened this issue Sep 6, 2019 · 4 comments · Fixed by #6

Comments

@ryan-roemer
Copy link

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
};
@lukejacksonn
Copy link
Owner

lukejacksonn commented Sep 9, 2019

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?

@ryan-roemer
Copy link
Author

Yep, exactly!

@lukejacksonn
Copy link
Owner

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!

@lukejacksonn
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants