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)
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
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.
Issue #2953
BUG: Error when navigating out from Grapes with something selected.
Hey @artf, Steps: Open Canvas with GrapesJS, select any of the components, then click on Go to Random, I get an error that says "Cannot rea...
Issue #3449
BUG: Switching pages calls canvas styles and scripts again and again
Hi I am integrating page manager into my project. But the issue I am facing is that whenever I switch between pages it loads CSS and script...
Issue #723
Changelog between versions
Hey Artur! I am not sure if "Issues" is the right page to write this because it is more of a suggestion. A Change Log is needed between Gra...
Issue #3083
[Feature]: Highlight drop zones
Hi @artf , How would you recommend highlighting the components on the canvas that the selected block can be dropped into based on draggable...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.