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

adding dist/react-magic-move.js after 0.13.1 react.js gives "Only a ReactOwner can have refs" error #8

Open
gojomo opened this issue Mar 24, 2015 · 3 comments

Comments

@gojomo
Copy link

gojomo commented Mar 24, 2015

I'd like to get the examples working in jsfiddles; to that end my understanding is that it should be possible to include the dist/react-magic-move.js script as a normal script reference, after the usual React support scripts (including the in-browser JSXTransformer).

However, my minimally-adapted version of the basic ('States') example on top of the "React Base Fiddle (JSX)" is triggering an odd React invariant error near the wrapup of the initial render: Invariant Violation: addComponentAsRefTo(...): Only a ReactOwner can have refs. This usually means that you're trying to add a ref to a component that doesn't have an owner (that is, was not created inside of another component'srendermethod). Try rendering this component inside of a new top-level component which will hold the ref.

The component-setup code is unchanged, so any owner-setup should still work. I thought it might be a problem specific to JSFiddle's panel setup, so I tried an entirely local-files setup – same error. I'm now thinking it may be a namespace issue arising from not loading-via-require()s, or an incompatibility with in-browser JSXTransformer use. (If the problem is either of these, it might merit a dist-script fix or doc note.)

You can view the error-triggering setup at: http://jsfiddle.net/69z2wepo/4692/

Any ideas?

@gojomo
Copy link
Author

gojomo commented Mar 24, 2015

Doesn't seem related to use of in-browser JSXTransformer – I get the same error with precompiled JSX: http://jsfiddle.net/5vjqabv3/325/.

@gojomo
Copy link
Author

gojomo commented Mar 27, 2015

At StackOverflow, someone pointing out another case where this error occurred, where the cause was multiple-definition of React classes, and that dist/react-magic-move.js repeats definitions from the standard react.js (and/or react-with-addons.js).

Is that intentional override/redefinition, and if so what's the right way to use the 'dist' form of react-magic-move? It seems not to mix well as a simple addition, loaded afterward.

@gojomo gojomo changed the title "Only a ReactOwner can have refs" error in JSFiddle-zed example adding dist/react-magic-move.js after 0.13.1 react.js gives "Only a ReactOwner can have refs" error Mar 27, 2015
@beeant
Copy link

beeant commented Apr 5, 2015

I got the same problem using the dist

var MagicMove = require('react-magic-move/dist/react-magic-move.min'); 

but when I use webpack with jsx-loader?harmony transformer, this problem is gone.

var MagicMove = require('react-magic-move'); 

and here are my webpack loaders for .js (I'm using react-jade for all of my React components)

[
  { test: /\.js$/, exclude: /node_modules/, loader: "transform?react-jade" },
  { test: /\.js$/, exclude: /public/, loader: 'jsx-loader?harmony' }
]

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

No branches or pull requests

2 participants