react-pageflip icon indicating copy to clipboard operation
react-pageflip copied to clipboard

No flip animation each page is rendering independantly

Open quteboy opened this issue 10 months ago • 6 comments

i am fetching a list of document from an api and its an array of object each object contains url key with s3 bucket url as value below code is rendering files but each page and pdf is rendering separately thus making page flip animation not working i think it is because of pagnumber calculation please provide support

{filteredData.map((item, index) => { return ( <Document key={index} file={item.url}> <HTMLFlipBook width={width} height={height}> <Page pageNumber={1} /> </HTMLFlipBook> </Document> ); })}

quteboy avatar Apr 24 '24 13:04 quteboy

const Page = React.forwardRef(({ pageNumber }, ref) => { return ( <div ref={ref} data-density="hard"> <ReactPdfPage pageNumber={pageNumber} width={width} /> </div> ); });

quteboy avatar Apr 24 '24 13:04 quteboy

You should be using only one HtmlFlipBook component. Currently you're rendering one HtmlFlipBook component per item in your map function.

Also you should probably use Document (pdf viewer) as a container for one Page.

grgicpetar avatar Apr 25 '24 07:04 grgicpetar

<HTMLFlipBook width={width} height={height}> {filteredData.map((item, index) => { return ( <Document key={index} file={item.url}> <Page pageNumber={1} /> </Document> ); })} </HTMLFlipBook>

like this ? if not please share correct code

quteboy avatar Apr 26 '24 11:04 quteboy

Yup, like that. Does it work now?

grgicpetar avatar Apr 29 '24 07:04 grgicpetar

console errors are cleaned but still rendering every pdf page individually

quteboy avatar May 02 '24 05:05 quteboy

{filteredData.map((item, index) => { return ( <Document key={index} file={item.url}> <HTMLFlipBook width={width} height={height}> {[...Array(item.numPages)].map((_, pageIndex) => ( <div className="demoPage" key={pageIndex}> <Page pageNumber={pageIndex + 1} width={width} height={height} /> </div> ))} </HTMLFlipBook> </Document> ); })} here is code that i have updated Please let me know

quteboy avatar May 02 '24 05:05 quteboy