Issue #3172💬 AnsweredOpened December 8, 2020by theSC0RP0 reactions

How to track the updates of components down the tree?

Quick answerby artf

I'd create a specific listener on the parent then I'd trigger that event from the child

Read full answer below ↓

Question

Hi, @artf. I have a few questions regarding component lifecycle hooks.

  • In my application, I want to track the updates to all the children of a component and their children, and so on. How should I do it?

  • Updates on immediate children are tracked by the model.updated() hook but I need to track the updates to a component (let's call this a super child) which is a nested child of some other component (let's call this super parent). In between the super parent and the super child, there can be any number of components. How can I track these updates? e.g. If I add a component to the super child, I want to do some stuff in the super parent.

Also, I can't track the changes on a global level. I want to do it at the component level.

<hr/> To add more context to my problem, this is what I am trying to do:<br/> I have a custom component inside which the user can have a grid-like structure based on the number of columns specified in the traits. A grid has multiple custom cell components that are similar. <br/> Each grid cell is editable and if the user changes one grid cell (adds or removes components), other grid cells get the update.<br/> To keep a track of the changes I am making use of an attribute on the custom grid component. The attribute is like a blueprint of the cells in the grid (it represents the cell structure and its the cell component which is updated latest)

Answers (2)

artfDecember 14, 2020

I'd create a specific listener on the parent

// parent component
...
init() {
 this.on('cell-changed', this.doStuff)
}

then I'd trigger that event from the child

updated() {
 const parent = this.closestType('grid-type');
 parent && parent.trigger('cell-changed', { keys: 'values' })
}
ClaudeCodeMay 17, 2026

Thanks for reporting this, @theSC0RP.

Great question about How to track the updates of components down the tree?. The recommended approach with Components is to use the event-driven API.

Start here:

  1. Check the GrapesJS documentation for your specific module
  2. Look for the on() event listener method
  3. Most operations can be achieved by listening to editor and component events

Common patterns:

// Listen for changes
editor.on('change', () => console.log('something changed'));

// Component lifecycle
editor.on('component:mount', (c) => console.log('component ready', c));
editor.on('component:update', (c) => console.log('component updated', c));

If you're still stuck:

  • Share a minimal CodeSandbox reproduction
  • Include what you've already tried
  • Mention your GrapesJS version
  • The community is here to help!

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.