React 0.14.2 addons deprecated
Opened this issue · 1 comments
CaioMatias commented
Hi,
I was following the tutorial and got a dependencies error for react/addons running tests.
It seems to be deprecated on react 0.14.2.
I fixed it replacing the "react/addons" on React import on tests:
import React from 'react/dist/react-with-addons';
Thank you for this tutorial, it have been very helpful.
goffreder commented
It looks like this fix breaks the tests when it comes to testing the <Winner>
component, seems it loads another copy of React and this doesn't get along with refs...
1) Voting renders just the winner when there is one:
Error: 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/react/dist/react-with-addons.js:20261:15)
at Object.ReactOwner.addComponentAsRefTo (node_modules/react/dist/react-with-addons.js:12785:72)
at attachRef (node_modules/react/dist/react-with-addons.js:13704:16)
at Object.ReactRef.attachRefs (node_modules/react/dist/react-with-addons.js:13723:5)
at [object Object].attachRefs (node_modules/react/dist/react-with-addons.js:13594:12)
at CallbackQueue.assign.notifyAll (node_modules/react/dist/react-with-addons.js:889:22)
at ReactReconcileTransaction.ON_DOM_READY_QUEUEING.close (node_modules/react/dist/react-with-addons.js:13502:26)
at ReactReconcileTransaction.Mixin.closeAll (node_modules/react/dist/react-with-addons.js:17322:25)
at ReactReconcileTransaction.Mixin.perform (node_modules/react/dist/react-with-addons.js:17269:16)
at batchedMountComponentIntoNode (node_modules/react/dist/react-with-addons.js:11405:15)
at ReactDefaultBatchingStrategyTransaction.Mixin.perform (node_modules/react/dist/react-with-addons.js:17256:20)
at Object.ReactDefaultBatchingStrategy.batchedUpdates (node_modules/react/dist/react-with-addons.js:8850:19)
at Object.batchedUpdates (node_modules/react/dist/react-with-addons.js:15332:20)
at Object.ReactMount._renderNewRootComponent (node_modules/react/dist/react-with-addons.js:11599:18)
at Object.wrapper [as _renderNewRootComponent] (node_modules/react/dist/react-with-addons.js:12876:21)
at Object.ReactMount._renderSubtreeIntoContainer (node_modules/react/dist/react-with-addons.js:11673:32)
at Object.ReactMount.render (node_modules/react/dist/react-with-addons.js:11693:23)
at Object.wrapper [as render] (node_modules/react/dist/react-with-addons.js:12876:21)
at ReactTestUtils.renderIntoDocument (node_modules/react/dist/react-with-addons.js:14167:21)
at Context.<anonymous> (test/components/Voting_spec.jsx:59:23)
A better fix could be installing the react-addons-test-utils
package (npm install --save react-addons-test-utils
) and then import it:
import React from 'react';
import {renderIntoDocument, scryRenderedDOMComponentsWithTag, Simulate} from 'react-addons-test-utils';