Skip to content
This repository has been archived by the owner on Nov 10, 2017. It is now read-only.

Please update the dependency for React-Native 0.43.x #95

Closed
xareelee opened this issue Apr 7, 2017 · 7 comments
Closed

Please update the dependency for React-Native 0.43.x #95

xareelee opened this issue Apr 7, 2017 · 7 comments

Comments

@xareelee
Copy link

xareelee commented Apr 7, 2017

I upgraded React-Native from 0.42.0 to 0.43.2, and I encountered new test errors Invariant Violation: addComponentAsRefTo(...):

  ● Storyshots › [App] Root › entry

    Invariant Violation: addComponentAsRefTo(...): Only a ReactOwner can have refs. You might be adding a ref to a component that was not created inside a component's `render` method, or you have multiple copies of React loaded (details: https://fb.me/react-refs-must-have-owner).
      
      at invariant (node_modules/fbjs/lib/invariant.js:44:15)
      at Object.addComponentAsRefTo (node_modules/react-test-renderer/lib/ReactOwner.js:68:68)
      at attachRef (node_modules/react-test-renderer/lib/ReactRef.js:23:16)
      at Object.<anonymous>.ReactRef.attachRefs (node_modules/react-test-renderer/lib/ReactRef.js:42:5)
      at ReactCompositeComponentWrapper.attachRefs (node_modules/react-test-renderer/lib/ReactReconciler.js:23:12)
      at CallbackQueue.notifyAll (node_modules/react-test-renderer/lib/CallbackQueue.js:76:22)
      at ReactTestReconcileTransaction.close (node_modules/react-test-renderer/lib/ReactTestReconcileTransaction.js:36:26)
      at ReactTestReconcileTransaction.closeAll (node_modules/react-test-renderer/lib/Transaction.js:206:25)
      at ReactTestReconcileTransaction.perform (node_modules/react-test-renderer/lib/Transaction.js:153:16)
      at batchedMountComponentIntoNode (node_modules/react-test-renderer/lib/ReactTestMount.js:69:27)

I found that I have two version of react in my node_modules according to yarn.lock.

react@16.0.0-alpha.6:
  version "16.0.0-alpha.6"
  resolved "https://registry.yarnpkg.com/react/-/react-16.0.0-alpha.6.tgz#2ccb1afb4425ccc12f78a123a666f2e4c141adb9"
  dependencies:
    fbjs "^0.8.9"
    loose-envify "^1.1.0"
    object-assign "^4.1.0"

react@^15.4.1:
  version "15.4.2"
  resolved "https://registry.yarnpkg.com/react/-/react-15.4.2.tgz#41f7991b26185392ba9bae96c8889e7e018397ef"
  dependencies:
    fbjs "^0.8.4"
    loose-envify "^1.1.0"
    object-assign "^4.1.0"

And I found only storyshots depends on react@^15.4.1:

storyshots@^3.2.2:
  version "3.2.2"
  resolved "https://registry.yarnpkg.com/storyshots/-/storyshots-3.2.2.tgz#0e2027a86acc319f8100124224f0e3f09c29efc8"
  dependencies:
    babel-runtime "^6.20.0"
    react "^15.4.1"
    react-test-renderer "^15.3.1"
    read-pkg-up "^2.0.0"

Is the dependency necessary? Or could you update the dependency to latest react (react@16.0.0)?

@ndelangen
Copy link
Contributor

You're using an alpha version of react: react@16.0.0-alpha.6
'latest' react is '15.4.2': '2017-01-06T20:16:25.738Z',. Our version range should allow this version to be de-duplicated (and does according to your yarn.lock).

I don't feel we can add a react alpha version into our version range. What do you think about this @mnmtanish ?

@xareelee
Copy link
Author

xareelee commented Apr 8, 2017

@ndelangen Thanks for your reply.

I'm using the latest React-Native (v0.43.x) which depends on react@16.0.0-alpha.6, and it leads the storyshots broken when jesting due to having multiple copies of React. We need the update for some fixes and features in RN 0.43.x.

Maybe we could modify the dependency of storyshots from ^15.4.1 to >=15.4.1 (not sure) or ^15.4.1 || >=16.0.0-alpha.6, and let the developers choose which version of React to be installed explicitly in package.json.

How about that?

@xareelee xareelee changed the title Please update dependency Please update the dependency for React-Native 0.43.x Apr 8, 2017
@ndelangen
Copy link
Contributor

If you edit the version range yourself and re-install does it work? If we're compatible with this version of React, I see no problem in adding it to our version range.

But if there's something we need to fix to support a alpha version, we can't just add it.

@thani-sh
Copy link

thani-sh commented Apr 8, 2017

@ndelangen yeah, we may end up making changes to storybook code to support alpha versions which may be unnecessary when the stable version comes out. @xareelee if it's okay, let's wait until an rc version comes out so it'll be stable enough.

@xareelee
Copy link
Author

xareelee commented Apr 8, 2017

Got it. I'll try it by myself.

If you edit the version range yourself and re-install does it work?

How do I do that? Do you mean forking this repo and using it as a private module?

@ndelangen
Copy link
Contributor

That's one way, you can also edit the installed package..

@xareelee
Copy link
Author

@ndelangen

  • I tried to edit the dependency in ./node_modules/storyshots/package.json and run yarn install, but it didn't work.
  • I tried to edit the dependency in yarn.lock and run yarn install, it seems OK. The tests are passed again.

Did I do right?

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

No branches or pull requests

3 participants