Issue #3381Opened April 2, 2021by pranay22101 reactions

BUG: Switching between components gives maximum call stack size error

Question

Hey artf, I would like to thank you for building such a powerful tool for building customized CMS.

I'm implementing a new page feature in my project so I'm using your reference to switch between components but It gives me an error, Please can you guide me on how to build a new page on click add new button from the panel?

Uncaught RangeError: Maximum call stack size exceeded
    at grapesjs:2
    at grapesjs:2
    at Te (grapesjs:2)
    at Module.Ae (grapesjs:2)
    at r.filter (grapesjs:2)
    at r.where (grapesjs:2)
    at Object.getSelector (grapesjs:2)
    at Object.get (grapesjs:2)
    at r.getAttributes (grapesjs:2)
    at r.toJSON (grapesjs:2)

Here is my code

var pages = [];

function changePage(index) {
    var page = { components: editor.getComponents(), style: editor.getStyle() };
    pages.splice(index, 0, page);
    console.log(pages)
    loadPage();
}

function loadPage() {
    var nextPage = pages[0];
    editor.setComponents(nextPage.components);
    editor.setStyle(nextPage.style);
}

Answers (2)

Ju99ernautApril 3, 20211 reactions

I think arrays aren't the best method of storing page objects, so running array operations to get the page plus loading the page is probably too much for your call stack. You should consider loading the pages into memory only when you need them and store them in something like a database instead of an array. You can try this plugin https://github.com/Ju99ernaut/grapesjs-template-manager

artfApril 20, 20210 reactions

I'm not sure what is happening on your side but I'd suggest keeping an eye on #3206 as the built-in page manager is almost ready (I'll update that issue)

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.