Issue #2660💬 AnsweredOpened March 16, 2020by just-vicu1 reactions

Reinit model's components function

Quick answerby artf1

I think this.components(this) will throw the Maximum call stack size exceeded error as you're trying to append the component to itself. Probably you have to try this I'd probably suggest, in this case, to isolate the function to make things more cleaner

Read full answer below ↓

Question

Hello guys, I have a custom component with different structure based on prop's value. How can i recall/reinit model's components function on prop change event. Thank you in advance.

Answers (2)

artfMarch 19, 2020

I think this.components(this) will throw the Maximum call stack size exceeded error as you're trying to append the component to itself. Probably you have to try this I'd probably suggest, in this case, to isolate the function to make things more cleaner

pouyamiralayiMarch 16, 2020

Hi @V1cu you can register your listeners inside the init hook like below:

model: {
            init() {
                this.listenTo(this, 'change:propName', () => this.components(this))
            },
}

Cheers!

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 →

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.