autoGenerateWrapperClass为null react-native

时间:2015-04-01 04:45:28

标签: javascript reactjs react-native

我正在为scala-js中的react-native编写包装器

  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())

组件注册正常,但在创建View元素时失败了!

  

null不是函数(评估'autoGenerateWrapperClass(tag)')“

完整堆栈跟踪:

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构建器的问题,它遵循ReactJS渲染API而不是AppRegistry,关闭问题。

1 个答案:

答案 0 :(得分:4)

如果您尝试呈现的组件未定义(as per this issue),则会看到此错误消息。在将component传递给registerComponent之前,{{1}}的价值是多少?