why does react to pdf cant see my tree data


i want to print my page on click but when im printing it it shows empty page on pdf file, any help?

import Tree from "react-hierarchy-tree-graph";
import Pdf from "react-to-pdf";

render(){
      const ref = React.createRef();
      console.log(ref)
        return(
          <div className="structureWrapper">
            <Pdf targetRef={ref} filename="code-example.pdf">
        {({ toPdf }) => <button onClick={toPdf}>Generate Pdf</button>}
      </Pdf>
        <div ref={ref} className="hrStructure">
            {this.state.data ? 
            <Tree
            data={this.state.data[0]}
            height={50}
            width={10000}
            orientation={"vertical"}
            translate={{x: 748, y: 201}}
            separation={{siblings: 4, nonSiblings: 3}}
            initialDepth={1}
            textLayout={{textAnchor: "start", x: -90, y: -20, transform: undefined }}
            /> : <div className="nav-loading"></div>
        }
        
    </div>
    </div>)
    }

Source: React – Stack Overflow

September 14, 2021
Category : News
Tags: javascript | react-to-pdf | reactjs | tree | treeview

Leave a Reply

Your email address will not be published. Required fields are marked *

Sitemap | Terms | Privacy | Cookies | Advertising

Senior Software Developer

Creator of @LzoMedia I am a backend software developer based in London who likes beautiful code and has an adherence to standards & love's open-source.