Issue #1183💬 AnsweredOpened June 7, 2018by syncubecommerce1 reactions

Grapesjs Plugins not loading second time in React SPA

快速解答by artf1

editor.destroy() method is available from https://github.com/artf/grapesjs/releases/tag/v0.14.20

Read full answer below ↓

Question

Hello,

I'm trying to add a grapesjs editor to my React SPA. I'm initializing editor this way:

componentDidMount() {
   const editor = grapesJs.init(config);
}

config variable has the following configuration:

plugins: ['gjs-preset-newsletter', 'gjs-aviary', 'gjs-plugin-ckeditor'],
pluginsOpts: {
        'gjs-preset-newsletter': {
            modalLabelImport: 'Paste all your code here below and click import',
            modalLabelExport: 'Copy the code and use it wherever you want',
            codeViewerTheme: 'material',
            cellStyle: {
                'font-size': '12px',
                'font-weight': 300,
                'vertical-align': 'top',
                color: 'rgb(111, 119, 125)',
                margin: 0,
                padding: 0,
            }
        }

The first time everything is working fine. When I navigate to another page of my single page app and get back - plugins are not loaded.

I tried to delete an instance of editor in componentWillUnmount() but it didn't help.

I tried to found solutions in issues but had no luck. Maybe I need somehow destroy editor in componentWillUnmount()?

Appreciate for your help.

Answers (3)

fernandoagarciaJune 15, 2018

I am having the a simliar issue. Except I am using VueJs. When I leave the page and comeback to it the editor runs the plugin again. This causes the editor to be unusable until I resize using the device preview but if I drag a block into the canvas it drops two times...one on where I dropped and the other down at the bottom.

fernandoagarciaJune 17, 2018

@artf yup that did the job perfectly ty!

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Free option

Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.

Browse free plugins →
Premium option

Premium plugins ship with support, regular updates, and production-ready features — save days of integration work.

Browse premium plugins →

Related tutorials

In-depth guides on the same topic.

All tutorials →

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.