Set content function empties the component content
you shouldn't use the content property, use selectedComponent.components(str)
Read full answer below βQuestion
I am trying to use the set function to change the content of a component, but actually the result is an empty component with nothing inside. This is an example with the code summarized Version used: 0.16.44 What is the expected behavior? The code executed should result in a component with text "foo" inside. What is the current behavior? The executed code empties the component content. In version 0.16.34 everything works as expected. Is there an workaround for this issue or should i stick with 0.16.34 verison ?
Answers (2)
you shouldn't use the content property, use selectedComponent.components(str)
Thanks for reporting this, @nairdapuiu. Great question about Set content function empties the component content. The recommended approach with Components is to use the event-driven API. Start here: Check the GrapesJS documentation for your specific module Look for the on() event listener method Mos...
Related Questions and Answers
Continue research with similar issue discussions.
Issue #3688
How to customize a component
I read this document https://grapesjs.com/docs/modules/Components.html#define-custom-component-type and tried to write the following code....
Issue #3174
Creating a new component type does not inherit the functions of it's parent type
Hello, I am trying to create a new common trait shared among all components by creating the following plugin on another plugin file I am al...
Issue #3713
Stored components with script can not be rendered properly
I am facing some problem when try to save some components which includes some scripts and reload the page the components are not rendered p...
Issue #3541
[QUESTION] What is the idiomatic way to append and remove classes from components?
Hey there π Love the editor! We're using traits to modify what classes a component has, but that feels a bit hacky as you have to redeclar...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.
Browse free plugins β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.
Tutorial
Big Updates: TinyMCE 8 and Placeholder 2.0 for GrapesJS
In May we shipped major updates to two of our most popular GrapesJS plugins β TinyMCE Inline Text Editor and Placeholder.
Tutorial
Find the Right GrapesJS Plugin in Seconds: Smarter Discovery Is Live
We're shipping a set of discovery upgrades. New label filters, a proper compatibility switch for GrapesJS vs Studio, one-click and a smarter sort bar.
Tutorial
GrapesJS vs Webflow vs Tilda (2026): Honest Comparison, Pricing & Which to Pick
GrapesJS vs Webflow vs Tilda compared head-to-head: real 2026 pricing, SEO features, code export, and which one actually fits your project
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.