Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

error Cannot read properties of undefined (reading 'height') at setNodeHeight #1602

Closed
jeetiss opened this issue Nov 19, 2021 Discussed in #1599 · 5 comments 路 Fixed by #1604
Closed

error Cannot read properties of undefined (reading 'height') at setNodeHeight #1602

jeetiss opened this issue Nov 19, 2021 Discussed in #1599 · 5 comments 路 Fixed by #1604
Assignees
Labels

Comments

@jeetiss
Copy link
Collaborator

jeetiss commented Nov 19, 2021

const Component = ({ name }) => {
    return (
        <>
            {name &&
            <Text>
                {name}
            </Text>}
        </>
    );
}

<Component name='' />
<Component name={0} />

Example above cause fatal errors in @react-pdf, but it should render nothing.

馃憠馃徎 repl

Discussed in #1599

Originally posted by joseDaKing November 17, 2021
I get this error in my code and I don't why

error:

TypeError: Cannot read properties of undefined (reading 'height')
at setNodeHeight

@mkamalkayani
Copy link

I also got this error. After trying out a lot of stuff, I realised that the extra ";" outside the Text and inside the View component was the reason for the error.

<View>
      <Text>some text</Text>;
</View>

@Nases
Copy link

Nases commented Dec 9, 2021

try

{ name ? <Text>{name}</Text> : null }

馃憠馃徎 repl

@jepek
Copy link

jepek commented Feb 15, 2022

In my case I just copied some example from docs and forgot to wrap the next inside <Page> with the <Text>

I had:

const MyDoc = (
  <Document>
    <Page size="A4">
      My document data
    </Page>
  </Document>
);

But it should be:

const MyDoc = (
  <Document>
    <Page size="A4">
      <Text>My document data</Text>
    </Page>
  </Document>
);

@doksel
Copy link

doksel commented Mar 17, 2022

You should just add styles to Text

const Component = ({ name }) => {
    return (
        <>
            {name &&
            <Text style={{height: 50}}>
                {name}
            </Text>}
        </>
    );
}

<Component name='' />

@Arthuru4
Copy link

Guess problem is that u wrap component with React.Fragment(<></>) - PDF does not understand what is that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants