Issue #1604Opened November 26, 2018by umairabid0 reactions

Issue with grapjs.init()

Question

Apparently options passed to grapjs.init() are not being deep cloned and same object is being mutated which was originally passed. This is creating a weird issue, I cannot do this

this._builder = grapesjs.init({
            container : '#gjs',
            plugins: ['gjs-preset-newsletter'],
            pluginsOpts: myOptions
});

Mutation can be seen by logging myOptions before init and the result is very weird, editor without any components

<img width="1440" alt="screen shot 2018-11-26 at 10 15 55 am" src="https://user-images.githubusercontent.com/2821084/48994313-634fd500-f164-11e8-9ab4-2e31b86717a7.png">

I had to fix it using cloneDeep of lodash like

this._builder = grapesjs.init({
            container : '#gjs',
            plugins: ['gjs-preset-newsletter'],
            pluginsOpts: cloneDeep(myOptions)
});

My version is "grapesjs": "^0.14.43",

Answers (2)

artfNovember 30, 20180 reactions

The option object is passed to the plugin as it is and there is no reason to clone it

lock[bot]November 30, 20190 reactions

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

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...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.