简体   繁体   English

使用fineuploader和react-rails

[英]Using fineuploader with react-rails

I'm trying to use fineuploader with react and have installed all the relevant dependencies. 我正在尝试使用fineuploader with react并安装了所有相关的依赖项。 Following is the code I use:- 以下是我使用的代码: -

 import React, { Component } from 'react' import FineUploaderTraditional from 'fine-uploader-wrappers' import Gallery from 'react-fine-uploader' import 'react-fine-uploader/gallery/gallery.css' const uploader = new FineUploaderTraditional({ options: { chunking: { enabled: true }, deleteFile: { enabled: true, endpoint: '/uploads' }, request: { endpoint: '/uploads' }, retry: { enableAuto: true } } }) class UploadComponent extends Component { render() { return ( <Gallery uploader={uploader} /> ) } } export default UploadComponent 

But I get the following errors:- 但我得到以下错误: -

Uncaught Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in. Check the render method of `Gallery`.
at invariant (invariant.js?7313:44)
at instantiateReactComponent (instantiateReactComponent.js?e676:74)
at instantiateChild (ReactChildReconciler.js?c86a:44)
at eval (ReactChildReconciler.js?c86a:71)
at traverseAllChildrenImpl (traverseAllChildren.js?5edf:77)
at traverseAllChildrenImpl (traverseAllChildren.js?5edf:93)
at traverseAllChildrenImpl (traverseAllChildren.js?5edf:93)
at traverseAllChildren (traverseAllChildren.js?5edf:172)
at Object.instantiateChildren (ReactChildReconciler.js?c86a:70)
at ReactDOMComponent._reconcilerInstantiateChildren (ReactMultiChild.js?e1f8:185)

Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. 警告:React.createElement:type无效 - 期望一个字符串(对于内置组件)或一个类/函数(对于复合组件)但得到:undefined。 You likely forgot to export your component from the file it's defined in. Check the render method of `Gallery`. 您可能忘记从其定义的文件中导出组件。检查`Gallery`的render方法。
in Gallery (created by UploadComponent) 在Gallery中(由UploadComponent创建)
in UploadComponent 在UploadComponent中

I've been following the react fineuploader documentation and I've tried a few different things but nothing seems to work. 我一直在关注反应的fineuploader文档,我尝试了一些不同的东西,但似乎没有任何工作。

Issue is some unmet dependency, which in my case was: 问题是一些未满足的依赖,在我的例子中是:

react-transition-group@1.x

I had 我有

react-transition-group@2.x

Removing 2.x and installing 1.2.1 fixed the problem. 删除2.x并安装1.2.1修复了问题。

Keep an eye on installation dependencies for any package you are trying to configure. 密切关注您尝试配置的任何软件包的安装依赖性。

Thanks to the react-fine-upload owner rnicholus for the help. 感谢反应精细上传所有者rnicholus的帮助。

I think you have to import Gallery component from module. 我认为你必须从模块导入Gallery组件。

import Gallery from 'react-fine-uploader'


Update: 更新:
Also try wraping Gallery inside a div 也尝试在一个div内包装Gallery

class UploadComponent extends Component {
    render() {
        return (
          <div>
            <Gallery uploader={uploader} />
          </div>
        )
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM