简体   繁体   English

反应 - 错误:“slate-react”不包含默认导出(作为“编辑器”导入)

[英]REACT - error: 'slate-react' does not contain a default export (imported as 'Editor')

I am confused by this.我对此感到困惑。 I couldn't find a solution.我找不到解决办法。

Returns an error:返回错误:

./src/components/TextEditor.js Attempted import error: 'slate-react' does not contain a default export (imported as 'Editor'). ./src/components/TextEditor.js 尝试导入错误:“slate-react”不包含默认导出(作为“编辑器”导入)。

import React, { Component } from 'react'
import Editor from 'slate-react'
import Value from 'slate'

const initialValue = Value.fromJSON({
    document: {
        nodes: [
            {
                object: 'block',
                type: 'paragraph',
                nodes: [
                    {
                        object: 'text',
                        leaves: [
                            {
                                text: 'A line of text in a paragraph.',
            },
        ],
    }, ],
}, ],
},
})



export default class TextEditor extends Component {

    state = {
        value: initialValue,
    }

    onChange = ({ value }) => {
        this.setState({ value })
    }

    render() {
        return (
            <Editor value={this.state.value} onChange={this.onChange} />
        )
        }
}

index指数

import TextEditor from './TextEditor';

export { TextEditor };

Editor and Value are named exports. Editor 和 Value 被命名为导出。

Replace:代替:

import Editor from 'slate-react'
import Value from 'slate'

with

import { Editor } from 'slate-react'
import { Value } from 'slate'

Those being named exports means you that have to import the precise name which is exported, and this goes within curly braces.那些被命名为导出意味着你必须导入导出的精确名称,这在花括号内。

See Slate doc请参阅Slate 文档

暂无
暂无

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

相关问题 错误:编辑器'未从'slate-react'导出 - Error: Editor' is not exported from 'slate-react' 检测在 slate-react 文本编辑器中选择了哪个节点 - Detecting which node is selected within a slate-react text editor 即使在 React 中正确导入后也不包含默认导出 - does not contain a default export even after being correctly imported in React CKEditor 错误:尝试导入错误:“ckeditor4-react”不包含默认导出(导入为“CKEditor”) - CKEditor error: Attempted import error: 'ckeditor4-react' does not contain a default export (imported as 'CKEditor') 尝试导入错误:“react-router-dom”不包含默认导出(导入为“useNavigate”) - Attempted import error: 'react-router-dom' does not contain a default export (imported as 'useNavigate') 反应 - 错误:尝试导入错误/应用程序'不包含默认导出(导入为'应用程序' - REACT - Error: Attempted import error/ App' does not contain a default export (imported as 'App' 尝试导入错误:“react-table”不包含默认导出(导入为“ReactTable”) - Attempted import error: 'react-table' does not contain a default export (imported as 'ReactTable') React JS 尝试导入错误:&#39;./Pathfinder/Pathfinder&#39; 不包含默认导出(导入为 &#39;Pathfinder&#39;) - React JS Attempted import error: './Pathfinder/Pathfinder' does not contain a default export (imported as 'Pathfinder') 尝试导入错误:&#39;react-lifecycles-compat&#39;不包含默认导出(导入为&#39;reactLifecyclesCompat&#39;) - Attempted import error: 'react-lifecycles-compat' does not contain a default export (imported as 'reactLifecyclesCompat') React-Redux:尝试导入错误:“./components/Score”不包含默认导出(导入为“Score”) - React-Redux: Attempted import error: './components/Score' does not contain a default export (imported as 'Score')
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM