Comments (6)
Hi.
I also catch this error in version 2.0.3, but my scenario slightly harder. I can remove and add pages without any problems, but when I try to remove and add pages at the same time the problem reproduced. It needed when the book has restrictions with blanc pages at the start and the end of the book. For example, I have restrictions:
- one blank page after the cover
- one blank page before the back cover
In this case, I should check even/odd pages and when the count of pages is odd, I must add an additional blank page.
If I understand correctly it happened, because the count of pages doesn't change https://github.com/Nodlik/react-pageflip/blob/master/src/html-flip-book/index.tsx#L65 and method refreshOnPageDelete() doesn't call.
Do you have any ideas How I/We can fix it? I have only 2 ideas:
- Automatical handling. The library will check is the count of pages is odd and is it add the blank page before back cover
- Add property renderForcePagesChange or something like this
// something like this
if (!props.renderOnlyPageLengthChange || props.renderForcePagesChange || pages.length !== childList.length) {
if (childList.length < pages.length || props.renderForcePagesChange) {
refreshOnPageDelete();
}
setPages(childList);
}
@Nodlik What do you think about it? I can prepare the pull request.
Thanks
from react-pageflip.
Try using the latest version. I hope I fixed it
from react-pageflip.
Yes it is partially supported.
But the children must be of the same type. Like here:
Also, please update StPageFlip to the latest version (0.4.3)
from react-pageflip.
If you put a button next to it that will perform setPages and insert the original array (for example), then there will be the same error as the author of the question
from react-pageflip.
I dug around in the code and it's caused by the library wrapping the pages into several other inner elements. React thinks the pages are the children of the div rendered in the HTMLFlipbook component but actually they are under the stf_wrapper and stf_block elements.
Unfortunately this is how far I've gotten. I don't know how to delete pages from the book though it would be important for some use cases. I might just move to vanilla JS though I started with React in the hope of easier DOM management.
from react-pageflip.
It looks like it's working now, I can add&remove pages without errors (though I am new to both React and Hooks and didn't know if I could make the changed HTMLFlipBook work in my class component so I spent a whole afternoon migrating to Hooks).
Thanks for the quick reply!
from react-pageflip.
Related Issues (20)
- Is there any way to interact with the content? HOT 1
- Unwanted line in Firefox
- Each child in a list should have a unique "key" prop error with child components HOT 1
- images displays blurry on ios HOT 1
- Odd number of images
- How to center the book on close?? HOT 1
- Issue with responsiveness. HOT 1
- can you please put an autoCenter functionality in the book? Because it's not centered when the book is closed. I want the book fully centered on both opening and closing. I am sure you will solve my problem. I am working on it for 1 month but I can't fix it. Thank you
- Can we change the animation of the flip ?
- UX: how to invite user interaction with a pageflip
- First page cover only HOT 2
- Nextjs ref is always null
- How to force 1 page only to be rendered on mobile? HOT 4
- There are click events in the content, seemingly can not prohibit bubbling, how to solve
- Can I put only image in page?
- Change Shadow flip color
- Flip corner animation doesn't have same effect as desktop on mobile
- Zoom in/out Functionality needs to add
- Animation from cover to first page on mobile looks different to example
- No flip animation each page is rendering independantly HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-pageflip.