2
我寫包裝器反應母語在斯卡拉-JSautoGenerateWrapperClass爲null反應母語
lazy val reactNative = js.Dynamic.global.require("react-native")
val View = reactNative.View
val component = ReactNativeB[Unit]("NativeYeah")
.render(P => {
reactNative.createElement(View,null)
}).buildU
reactNative.AppRegistry.registerComponent("iOSscala",() => component())
組件註冊精細,但其未能在創建視圖元素!
null不是(評估 'autoGenerateWrapperClass(標籤)')」
完整的堆棧跟蹤功能:
CTJSLog> "Error:
stack:
getComponentClassForElement index.ios.bundle:5894
validatePropTypes index.ios.bundle:5634
createElement index.ios.bundle:5681
renderApplication index.ios.bundle:33913
run index.ios.bundle:33858
runApplication index.ios.bundle:33880
jsCall index.ios.bundle:7237
_callFunction index.ios.bundle:7484
applyWithGuard index.ios.bundle:877
guardReturn index.ios.bundle:7286
callFunctionReturnFlushedQueue index.ios.bundle:7493
URL: http://localhost:8081/index.ios.bundle
line: 5894
message: null is not a function (evaluating 'autoGenerateWrapperClass(tag)')"
在調試這個功能
function getComponentClassForElement(element) {
if (typeof element.type === 'function') {
return element.type;
}
var tag = element.type;
var componentClass = tagToComponentClass[tag];
if (componentClass == null) {
tagToComponentClass[tag] = componentClass = autoGenerateWrapperClass(tag);
}
return componentClass;
}
標籤值是ReactElement
注意:上面的代碼在使用div標籤/ react組件的reactjs中正常工作。
編輯:它的問題來自scalajs-react builder,它遵從ReactJS渲染API而不是AppRegistry,關閉問題。
我覺得組件很好,組件是ReactComponentU(un mounted)的一個實例。同時註冊var componentClass = ReactNativeComponent.getComponentClassForElement( element );這行很好,甚至我可以看到組件名稱。唯一失敗的部分是創建視圖元素,我相信! – invariant 2015-04-01 13:59:57
好的,當它傳遞給createElement時,View的價值是什麼? – 2015-04-01 14:07:10
reactNative.View – invariant 2015-04-01 14:09:12