-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot read property 'layout' of null #284
Comments
My documents rendered fine in alpha.12. After upgrading, I did a global replace for |
Could you provide a snippet that replicates this error? |
happenned to me too. I am upgrading from 12 to 14 too. I tried what kind of snippet do you require @diegomura ? edit: forget to mention, I try the code provided in this repo's readme.md (how it works) and it works. |
Sorry I didn't have a good code snippet. I noticed that I'm getting the error on alpha 12 as well. I'm downgrading to alpha 10 to see if the issue still persists. |
Another observation: I wasn't able to reproduce the error locally that I was seeing on my production server, so it may be OS specific |
I put a debugger to try to see the state when the |
I don't get the same error with alpha 8 |
Thanks guys. So apparently is an issue that ha been present for awhile now, and not introduced in the last version, right? |
hei, I found a weird case regarding the
will not render, but add a single space to the first line becoming:
it will render. I meant, in my previous code, I think a line only containing |
I also noticed this issue. I need to render dynamic value in pdf from so this works - so this confirms @ybbond observation, that this happens when there are empty lines in a text |
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); |
Here is a simple repro for this (which I'm still seeing on alpha.18) const str = `
`
const Quixote = () => (
<Document>
<Page style={styles.body} wrap>
<Text style={styles.header} fixed>
{str}
</Text>
</Page>
</Document>
); I haven't been able to test this with the latest commit that fixed the empty string, which may address this case. How would I test an unreleased version in my package.json? Happy to test with unreleased, just don't know the correct way. |
Thanks @bkoltai There's no neat way of use an unrealeased version yet. You can always use the github url in package.json, but what this library actually publishes is the builds. I guess if you run However, I thing this issue is related to |
Fixed react-pdf/textkit#1 TODO:
|
Fixed in new |
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
The text was updated successfully, but these errors were encountered: