react-copy-write icon indicating copy to clipboard operation
react-copy-write copied to clipboard

Unable to use in a new React Native project

Open aweary opened this issue 7 years ago • 5 comments

When importing react-copy-write in a React Native project it complains about it using Babel 7. I'm not sure why that would matter, but react-copy-write should work with RN out of the box.

aweary avatar Apr 15 '18 04:04 aweary

This is a weird one. I tried a bunch of tweaks/hacks but couldn't figure it out. The library works fine in RN if you copy out the built lib/index.js and import it locally (as expected).

Know any babel/RN experts? 😛

wKovacs64 avatar Apr 15 '18 23:04 wKovacs64

I finally found the time to dig a little deeper and I think this is broken because the current version of React Native (0.55) depends on a version of Metro (0.30.0) that does not work with Babel 7 (see https://github.com/facebook/metro/issues/92). It sounds like newer versions of Metro will work with Babel 7, but projects currently using Babel 7 will remain incompatible with React Native until a newer version is released that depends on an updated version of Metro (which should be the next RN release).

As I see it, there are 2 choices:

  1. Wait it out. RN users will not (easily) be able to use react-copy-write for the time being.
  2. Temporarily downgrade Babel to v6 to accommodate RN users until the next version is released.

Thoughts, @aweary?

wKovacs64 avatar May 23 '18 22:05 wKovacs64

@aweary Since the latest version of react-native (0.56.0) is using Babel 7 it seems there is no problem to use the react-copy-write in a react-native project. I inited a new react-native project and tested react-copy-write in it and everything worked great.

VahidBo avatar Jul 16 '18 20:07 VahidBo

Awesome, thanks for checking and letting me know @VahidBo! and thanks for investigating it in the first place @wKovacs64

aweary avatar Jul 16 '18 23:07 aweary

Re-opening, since apparently Expo still uses an older version of React Native. Since Expo is relatively popular, we should try to support it out of the box as well.

aweary avatar Oct 08 '18 17:10 aweary