编程语言
首页 > 编程语言> > javascript – 使用fine -loader和react-rails

javascript – 使用fine -loader和react-rails

作者:互联网

我正在尝试使用fineuploader with 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

我一直在关注反应的fineuploader文档,我尝试了一些不同的东西,但似乎没有任何工作.

解决方法:

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

react-transition-group@1.x

我有

react-transition-group@2.x

删除2.x并安装1.2.1修复了问题.

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

感谢react-fine-upload拥有者rnicholus 的帮助.

标签:javascript,ruby-on-rails,reactjs,fine-uploader
来源: https://codeday.me/bug/20190828/1750190.html