gerhardsletten / react-reader

An ePub-reader for React, powered by Epub.js
https://react-reader.metabits.no
Apache License 2.0
676 stars 130 forks source link

Update minimal example code in README.md #164

Closed luciancic closed 10 months ago

luciancic commented 11 months ago

Loving this lib. But got tripped up by the minimal example. Proposing 3 changes:

  1. Props used were incorrect.
  2. Changed typo in arg epubcifi. Should be epubcfi (CFI is canonical fragment identifier, today I learned something new 🎉).
  3. Changed the default state from 0 to null because I had issues with several books where it would render at the cover page but I could not navigate from it until I used the TOC, but as soon as I changed the 0 to 1 or null it would work, because it would start off after the cover page.

Some extra notes on point 3: I got this error with the default "https://react-reader.metabits.no/files/alice.epub", and I tested with other books too, mostly from https://www.epubbooks.com/. I'm wondering if I'm the only one who had that issue, I could not find any issues or discussion about this here. I tried validating the epubs using https://www.epubvalidation.com and got this error: Non-linear content must be reachable, but found no hyperlink to "OEBPS/cover.xhtml" I'm using this in a capacitor app, latest react-reader version, same issue on all platforms. Maybe point 3 is more contentious and could require some discussion, so we could leave it out of the PR and just do 1 and 2, and open an issue for 3? Any thoughts?

vercel[bot] commented 11 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-reader ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 19, 2023 9:04pm
gerhardsletten commented 10 months ago

@luciancic Thanks, as you said I have also experienced the issue that some books dont react to the next button, but I have not connected it to having a zero number ;-)

Not sure null is a good option though, it might be that loction only should be a string, since that is what epubjs is passing back in the loctionChange.

gerhardsletten commented 10 months ago

@luciancic Have added null as a allowed type for location-prop, but I reverted the change inital type in example, since I think 0 is a better inital prop when you open an new epub (and dont have a previous location to restore).

As you mention there was something missing in the epub, so I did update the alice-example from gutenberg, and now setting inital loction to 0 dont break the next page button. See example here https://react-reader.metabits.no/

Thank for your help and the update is published in react-reader@2.0.4