React 0.18 导致模块错误

Posted

技术标签:

【中文标题】React 0.18 导致模块错误【英文标题】:React 0.18 causes Module error 【发布时间】:2016-01-27 14:39:17 【问题描述】:

在更新到 React Native 0.18 后尝试让模块工作时出现以下错误:

com.lwansbrough.RCTCamera.RCTCameraViewManager 无法转换为 com.facebook.react.uimanager.ViewGroupmanager

导致此类错误的原因是什么,如何解决?

这是 RCTCameraViewManager 的代码:

package com.lwansbrough.RCTCamera;

import android.support.annotation.Nullable;
import com.facebook.react.uimanager.*;

public class RCTCameraViewManager extends SimpleViewManager<RCTCameraView> 
    private static final String REACT_CLASS = "RCTCameraView";

    @Override
    public String getName() 
        return REACT_CLASS;
    

    @Override
    public RCTCameraView createViewInstance(ThemedReactContext context) 
        return new RCTCameraView(context);
    

    @ReactProp(name = "aspect")
    public void setAspect(RCTCameraView view, int aspect) 
        view.setAspect(aspect);
    

    @ReactProp(name = "captureMode")
    public void setCaptureMode(RCTCameraView view, int captureMode) 
        // TODO - implement video mode
    

    @ReactProp(name = "captureTarget")
    public void setCaptureTarget(RCTCameraView view, int captureTarget) 
        // No reason to handle this props value here since it's passed again to the RCTCameraModule capture method
    

    @ReactProp(name = "type")
    public void setType(RCTCameraView view, int type) 
        view.setCameraType(type);
    

    @ReactProp(name = "torchMode")
    public void setTorchMode(RCTCameraView view, int torchMode) 
        view.setTorchMode(torchMode);
    

    @ReactProp(name = "flashMode")
    public void setFlashMode(RCTCameraView view, int flashMode) 
        view.setFlashMode(flashMode);
    

    @ReactProp(name = "orientation")
    public void setOrientation(RCTCameraView view, int orientation) 
        view.setOrientation(orientation);
    

    @ReactProp(name = "captureAudio")
    public void setCaptureAudio(RCTCameraView view, boolean captureAudio) 
        // TODO - implement video mode
    

【问题讨论】:

【参考方案1】:

我也遇到了这个错误,我的解决办法是改变

public class RCTCameraViewManager extends SimpleViewManager<RCTCameraView>

public class RCTCameraViewManager extends ViewGroupManager<RCTCameraView>

【讨论】:

以上是关于React 0.18 导致模块错误的主要内容,如果未能解决你的问题,请参考以下文章

模块暴露在Elm 0.18中

require(variable) 导致错误找不到模块“。”

未捕获的错误:找不到模块“react/jsx-runtime”

scikit-learn 0.18中的cross_validation模块被移除

错误:index.js:找不到模块'babel-plugin-r' React Native

React-Native:啥会导致模块为空?