将 fineuploader 与 react-rails 结合使用

Using fineuploader with react-rails

我正在尝试将 fineuploader 与 react 一起使用,并且已经安装了所有相关的依赖项。 以下是我使用的代码:-

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

但是我得到以下错误:-

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. You likely forgot to export your component from the file it's defined in. Check the render method of `Gallery`.
in Gallery (created by UploadComponent)
in UploadComponent

我一直在关注 React fineuploader 文档,我尝试了一些不同的方法,但似乎没有任何效果。

我认为您必须从模块中导入 Gallery 组件。

import Gallery from 'react-fine-uploader'


更新:
也可以尝试将 Gallery 包裹在 div

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

问题是一些未满足的依赖关系,在我的例子中是:

react-transition-group@1.x

我有

react-transition-group@2.x

删除 2.x 并安装 1.2.1 解决了问题。

密切关注您尝试配置的任何软件包的安装依赖项。

感谢react-fine-upload版主rnicholus 的帮助