【问题标题】:Using fineuploader with react-rails将 Fineuploader 与 react-rails 一起使用
【发布时间】:2017-10-03 08:55:00
【问题描述】:

我正在尝试将 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)

警告:React.createElement:类型无效——需要一个字符串 (对于内置组件)或类/函数(对于复合 组件)但得到:未定义。您可能忘记导出您的 组件从它定义的文件中。检查渲染方法 `图库`。
在图库中(由 UploadComponent 创建)
在上传组件中

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

【问题讨论】:

    标签: javascript ruby-on-rails reactjs fine-uploader


    【解决方案1】:

    问题是一些未满足的依赖关系,在我的情况下是:

    react-transition-group@1.x
    

    我有

    react-transition-group@2.x
    

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

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

    感谢 react-fine-upload 所有者 rnicholus 的帮助。

    【讨论】:

    • 你是救生员!!!我整天都在网上寻找解决方案。
    【解决方案2】:

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

    import Gallery from 'react-fine-uploader'


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

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

    【讨论】:

    • 你能发布你现在得到的完整错误堆栈跟踪吗(尝试重新加载服务器)?
    • 我在服务器中没有收到任何错误。我得到的唯一错误是在浏览器的控制台中。
    • 我遇到了和以前一样的错误。我在问题中提到的那些。
    • 这是图库组件,如果有帮助的话。 1drv.ms/u/s!AiuVKFBrrB6DtysP8M_BjKPhsLW1
    • 它是画廊类的缩小版。我可以在他们的 git repo github.com/FineUploader/react-fine-uploader/blob/master/src/… 中看到它。我不认为 Gallery 组件有什么问题。我认为您在导入时遗漏了一些东西。
    猜你喜欢
    • 1970-01-01
    • 2015-07-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-20
    • 2018-07-18
    • 2017-01-13
    • 1970-01-01
    相关资源
    最近更新 更多