本文介绍了为什么React-Magic-Move示例在JSFiddle中以“只有ReactOwner可以具有引用"才能中断?错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获得漂亮的 react-magic-move react-magic-move的基本"(美国)示例. a>在JSFiddle工作的组件,用于修补. (另请参见 https://www.youtube.com/watch?v=z5e7kWSHWTg#t上令人印象深刻的视频演示= 424 )

I'd like to get the 'basic' (US States) example of the nifty react-magic-move component working at JSFiddle, for tinkering. (See also impressive video demo at https://www.youtube.com/watch?v=z5e7kWSHWTg#t=424)

我已经将react-magic-move'dist'脚本添加到了Base React(JSX)小提琴中,以及其他(最低适应性)示例JS/CSS/HTML.您可以在此处看到尝试:

I've added the react-magic-move 'dist' script to the Base React (JSX) fiddle, plus the other (minimally-adapted) example JS/CSS/HTML. You can see the attempt here:

http://jsfiddle.net/69z2wepo/4692/

但是,它会在初始渲染后期触发错误:

However, it's triggering an error late-in-initial-rendering:

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's 'render' method). Try rendering this component inside of a new top-level component which will hold the ref.

很明显,它正在加载MagicMove代码并成功完成了大多数渲染:出现错误后,便已组装了真实DOM.在React之后应该包括dist脚本就可以了.

It's clearly loading the MagicMove code and succeeding on most of the rendering: after the error, the real-DOM has been assembled. Including the dist script after React ought to work.

我认为这可能是JSFiddle窗格特有的问题,所以我尝试在本地文件中进行相同的设置:相同的错误.考虑到这可能是浏览器中的JSX交互,我尝试了预编译的JSX:相同的错误. (请参见 http://jsfiddle.net/5vjqabv3/325/).首先得到React 0.13.1的错误;尝试回滚到0.12.0的基本提琴:相同的错误. (请参见 http://jsfiddle.net/kb3gN/10548/)

Thinking it might be a problem specific to JSFiddle's panes, I tried the same setup in local files: same error. Thinking it might be a JSX-in-browser interaction, I tried precompiled JSX: same error. (See http://jsfiddle.net/5vjqabv3/325/). First got the error with React 0.13.1; tried rolling back to 0.12.0's base fiddle: same error. (See http://jsfiddle.net/kb3gN/10548/)

在发生异常时,当前元素(ReactElement,div,ref'AL')具有空的_owner属性-似乎不正确.

At the moment of the exception, the current element (ReactElement, div, ref 'AL') has a null _owner property – which seems off.

有什么想法会阻止建立必要的React-owner-relationship?以这种所需的先加载后反应"方式,react-magic-move dist脚本是否损坏或无法使用?

Any ideas what's preventing the necessary React-owner-relationship from being set up? Is the react-magic-move dist script broken or otherwise unusable in this desired 'load-after-React' manner?

推荐答案

这是我为使示例在本地工作所做的

This is what I did to get the examples working locally

git clone [email protected]:ryanflorence/react-magic-move.git
cd react-magic-move
npm install
scripts/dev-examples

现在在浏览器中打开 http://localhost:8080/basic/,它会以某种方式工作

now open up http://localhost:8080/basic/ in your browser, and it works somehow

这篇关于为什么React-Magic-Move示例在JSFiddle中以“只有ReactOwner可以具有引用"才能中断?错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 21:39