question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Blocks#render doesn't work (API)

See original GitHub issue

Hello. I have a basic editorJS setup, with only the header tool and a testtool. I’m trying to use the blocks#render function in the API. This is my tool.

class MyTool {
  constructor({data, api}){
    this.api = api;
    // ...
    setTimeout(() => {
      this.test();
    }, 1000);
  }

  test() {
    this.api.blocks.render(
      [
        {
          type: "header",
          data: {
             text: "New header",
             level: 2
          }
        }
      ]
    );
  }
}

It’s almost a direct copy from the docs.

When I load the page, everything is fine. After one second the function “test” is called and the editor is blank.

I get this error in my console.

Uncaught (in promise) TypeError: Cannot read property 'map' of undefined
    at e.<anonymous> (editorjs@latest:6)
    at c (editorjs@latest:6)
    at Generator._invoke (editorjs@latest:6)
    at Generator.forEach.t.<computed> [as next] (editorjs@latest:6)
    at c (editorjs@latest:6)
    at e (editorjs@latest:6)
    at editorjs@latest:6
    at new Promise (<anonymous>)
    at r (editorjs@latest:6)
    at S._invoke (editorjs@latest:6)

Am I doing something wrong or is this a bug?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
findelacommented, Jul 30, 2020

The documentation site of this plugin is limited, unclear, less example oriented, more worried and very poor in knowledge base. It’s only super-heroic to ninja people or for those stupid folks who built this.

0reactions
Paultje52commented, May 23, 2020

@psdon is editor.js ready before you try it?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I block a React component to be rendered until I ...
The information will be provided by an API and fetched with an ajax call. I'm just trying to wait 10 seconds before rendering...
Read more >
9 tricks to eliminate render blocking resources - LogRocket Blog
By reducing render blocking resources, you can shorten the critical rendering path and reduce page load times, thus improving UX and SEO.
Read more >
Dynamic render blocks support (API rework using WordPress ...
Wordpress Gutenberg supports dynamic block use-case (through the use of render_callback ) where developers are capable of doing the rendering ...
Read more >
Remove Render-Blocking JavaScript | PageSpeed Insights
You should avoid and minimize the use of blocking JavaScript, especially external scripts that must be fetched before they can be executed.
Read more >
PerformanceResourceTiming.renderBlockingStatus - Web APIs
Render -blocking resources are static files, such as fonts, CSS, and JavaScript that block or delay the browser from rendering page content ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found