Parser bug inside Remix
@wunksert it seems like the editor initializes on itself multiple times, are you properly clearing the editor instance with destroy (eg. in your useEffect)?
Read full answer below βQuestion
GrapesJS version
- I confirm to use the latest version of GrapesJS
What browser are you using?
Chrome v114
Reproducible demo link
https://github.com/wunksert/remix-grapes-error/tree/main
Describe the bug
How to reproduce the bug?
-
Clone repo above
-
npm i
-
npm run dev you'll see that the grapes iframe and boilerplate is rendered into the canvas.
-
Try to export and you'll see that all the grapes boilerplate is also rendering into the canvas
-
Open dev tools and you'll see the error:
Component.ts:910 Uncaught (in promise) TypeError: Cannot read properties of null (reading 'querySelector')
at o2.getBody (Component.ts:910:16)
at o4._upFrame (sample.js:20:20)
at min.js:12:54
at Array.forEach (<anonymous>)
at o4.toggleVis (min.js:12:21)
at o4.run (max.js:13:7)
at e3.callRun (ShowOffset.ts:16:26)
at o2.runCommand (index.ts:805:3)
at n2.updateActive (PropertyFactory.ts:421:47)
at g (backbone.js:482:10)
Additional context
What is the expected behavior? The editor should render it's boilerplate properly, the same way as it
What is the current behavior? The parser doesn't seem to work. The editor renders the iframe that's meant to encapsulate the editor DOM. It also exports all the grapesJS boilerplate.
If is necessary to execute some code in order to reproduce the bug, paste it here below:
Code of Conduct
- I agree to follow this project's Code of Conduct
Answers (4)
@wunksert it seems like the editor initializes on itself multiple times, are you properly clearing the editor instance with destroy (eg. in your useEffect)?
It might turn out that a fix for this is more simply solved by me editing structure or naming conventions in my project. Happy to do that if it's faster than changing something in GrapesJS core.
yeah definitely not related to the core
Thanks for reporting this, @wunksert.
Great question about Parser bug inside Remix. The recommended approach with Canvas is to use the event-driven API.
Start here:
- Check the GrapesJS documentation for your specific module
- Look for the
on()event listener method - 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.
Issue #4576
Clicking 'wrap for style' button affects the inner components of other components inside the same text box
GrapesJS version[X] I confirm to use the latest version of GrapesJSWhat browser are you using? Chrome 104.0.5112.101 Reproducible demo link...
Issue #4474
Running in headless mode requires window
GrapesJS version[X] I confirm to use the latest version of GrapesJSWhat browser are you using? Chrome 103.0.5060.134Reproducible demo link...
Issue #6666
Layer panel: drag and drop makes items disappear (firefox and chrome)
GrapesJS version [x] I confirm to use the latest version of GrapesJS What browser are you using? Firefox 137.0 and Chrome 136.0.7103.92 Rep...
Issue #6685
Custom component styles are not applied after deletion and re-addition
GrapesJS version [x] I confirm to use the latest version of GrapesJS What browser are you using? Chrome v143.0.7499.193 Reproducible demo l...
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
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
GJS Market 2.0 - Donations, Tracking, Labels and Better Product Discovery
Weβve rolled out a new set of GrapesJS marketplace updates across GJS Market, focused on improving how creators distribute products
Tutorial
Preset DevFuture 2.0 β New Update Released
Preset continues evolving as a clean, production-ready starting point for building visual editors powered by GrapesJS
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.