aweary / react-copy-write

✍️ Immutable state with a mutable API
MIT License
1.79k stars 54 forks source link

Unable to use in a new React Native project #7

Open aweary opened 6 years ago

aweary commented 6 years ago

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.

wKovacs64 commented 6 years ago

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 commented 6 years ago

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?

VahidBo commented 6 years ago

@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.

aweary commented 6 years ago

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

aweary commented 6 years ago

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.