PejmanNik / jikji

Effortless report generator and reporting tools with React and NodeJS
https://jikji.xyz
MIT License
45 stars 1 forks source link

usePageInfo doesn't work in the PageContent #16

Closed PejmanNik closed 11 months ago

PejmanNik commented 11 months ago

usePageInfo hook returns the default value when it used inside the PageContent

https://codesandbox.io/s/jikji-test-page-number-8cvsq3

sharathm89 commented 11 months ago

Any update on this ticket ...

PejmanNik commented 11 months ago

No, against my first guess, it is not easy to fix as at the time of splitting components in page content the usePageInfo hook returned 0, and the component converted to a Fragment

as a workaround for now, you can put your logic in a separate component (that return null, render nothing) and uses usePageInfo inside it, then wrap it in with Layout component (with disableSnapshot)

 <Layout disableSnapshot>
     <PageNumberLogic />
 </Layout>
sharathm89 commented 11 months ago

@PejmanNik I'm sorry, I didn't understand...

Is it possible to create a sample code in codesandbox demonstrating it.

PejmanNik commented 11 months ago

https://codesandbox.io/s/jikji-test-page-number-forked-mggzy2?file=/src/App.tsx

sharathm89 commented 11 months ago

Thanks... Its working.