首页 > 解决方案 > 如何在 React 应用程序中使用 front/gutenberg-js?

问题描述

我已经使用 create-react-app cli 创建了一个反应应用程序。该应用程序运行良好。我必须使用 wordpress 5 中的古腾堡编辑器。

在https://github.com/front/gutenberg-js中有一个仅 javascript 版本可用。问题是当我尝试 domReady 时,使用以下 import 语句编辑发布这些内容

import { domReady, editPost } from '@frontkom/gutenberg-js';

我的反应应用程序不工作,

下面是例外

gutenberg-js.js:104 Uncaught TypeError: Cannot read property 'createContext' of undefined
    at Module.push../node_modules/@frontkom/gutenberg-js/build/js/gutenberg-js.js (gutenberg-js.js:104)
    at n (gutenberg-js.js:17)
    at Module.push../node_modules/@frontkom/gutenberg-js/build/js/gutenberg-js.js (gutenberg-js.js:45274)
    at n (gutenberg-js.js:17)
    at push../node_modules/@frontkom/gutenberg-js/build/js/gutenberg-js.js (gutenberg-js.js:51)
    at Object../node_modules/@frontkom/gutenberg-js/build/js/gutenberg-js.js (gutenberg-js.js:52)
    at __webpack_require__ (bootstrap:781)
    at fn (bootstrap:149)
    at Module../src/components/PageEditor.js (HomeComponent.js:13)
    at __webpack_require__ (bootstrap:781)
    at fn (bootstrap:149)
    at Module../src/index.js (index.css?f3f6:45)
    at __webpack_require__ (bootstrap:781)
    at fn (bootstrap:149)
    at Object.0 (store.js:12)
    at __webpack_require__ (bootstrap:781)
    at checkDeferredModules (bootstrap:45)
    at Array.webpackJsonpCallback [as push] (bootstrap:32)
    at main.chunk.js:1

期望进口应该起作用。

标签: wordpress-gutenbergproject-gutenberg

解决方案


推荐阅读