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.

Cannot read property 'layout' of null

See original GitHub issue

React-pdf version: 1.0.0-alpha.14

Description: After upgrading, I now see the following error when trying to render any document. I’m not setting any custom fonts


Uncaught (in promise) TypeError: Cannot read property 'layout' of null
    at GlyphGenerator.js:63
    at Array.map (<anonymous>)
    at GlyphGenerator.generateGlyphs (GlyphGenerator.js:61)
    at LayoutEngine$$1.layoutParagraph (LayoutEngine.js:119)
    at LayoutEngine$$1.layoutColumn (LayoutEngine.js:94)
    at LayoutEngine$$1.layout (LayoutEngine.js:80)
    at TextEngine.layout (react-pdf.browser.es.js:3662)
    at Text.measureText (react-pdf.browser.es.js:3872)
    at External.data (entry-common.js:221)
    at Array.eval (eval at buildJSCallerFunction (nbind.js:1449), <anonymous>:1:86)
    at Array.ASM_CONSTS (nbind.js:557)
    at _emscripten_asm_const_iiididi (nbind.js:565)
   ...

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:16 (14 by maintainers)

github_iconTop GitHub Comments

1reaction
nicolasraynaud-millevoltscommented, Sep 5, 2018

If it can help someone, here is a small code to make a safe Text component (really improvable):

import {
  Text as UnsafeText
} from "@react-pdf/renderer";

function safeText(text) {
  const str = text
    ? Array.isArray(text) ? "" + text.join("") : "" + text
    : "";
  return str
    .replace(/\n\n/gim, "\n \n")
    .replace(/\n\n/gim, "\n \n")
    .replace(/ $/, " ");
}

function toSafeText(Component) {
  return function({ children, ...props }) {
    return <Component {...props} children={safeText(children)} />;
  };
}

const Text = toSafeText(UnsafeText);
0reactions
diegomuracommented, Oct 24, 2018

Fixed in new 1.0.0-alpha.19 version

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot read properly 'data ' of null (DASH) - Stack Overflow
Sometimes Dash can struggle if the prop being updated by a callback hasn't been initialized. In this case, the figure prop of the...
Read more >
Dash Upload data Update graph with callback - Cannot read ...
I'm new to Dash and trying to create a dashboard with upload data function and graph update with callbacks. However I got this...
Read more >
how to fix this error Cannot read property of null (reading 'style')
Hi Andrew,. he's just saying that boxElement is null. That is always (or at least often) a possibility, so you should check for...
Read more >
Image not displaying and giving error "Cannot read property ...
Within the standard Community Designer the image within the Layout is not being displayed and shows an error. When you return to the...
Read more >
Dashboard fails to load with error "Uncaught TypeError
... Cannot read property 'left' of null" appears in the browser console ... and 3 functionality buttons (Add Gadget, Edit Layout, Tools) are...
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