Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All the optional props are required #32

Open
marked29 opened this issue Mar 24, 2022 · 5 comments
Open

All the optional props are required #32

marked29 opened this issue Mar 24, 2022 · 5 comments

Comments

@marked29
Copy link

Hello

I used react-pageflip on my pet project which was written in ReactJS using TypeScript as well and there was one problem regarding props . Documentation says that the only required props for HTMLFlipBook are width and height but in real use it turned out that not only these props are required.

I checked node_modules/react-pageflip and it turned out that a lot of props are required indeed. I provided local solution for my project but I reckon that some changes should happen in original code base that it could correspond to the documentation and not to be confusing.

I can fix the issue if you want me to fix it.

Best regards,
Mark

@YoonJeongLulu
Copy link

How can I see your local solution?

@aldrichdev
Copy link

I am also getting this issue.

image

I imported HTMLFlipbook like this:

import HTMLFlipBook from 'react-pageflip'

Even if I add all the required properties with default values, I get an error Invalid flipping time once the PDF loads.

@umair-dmechs
Copy link

Getting the same issue. You must have to make the optional props to be optional props. currently, almost every prop is a required prop.

Screenshot 2023-01-10 at 5 05 58 PM

@ghost
Copy link

ghost commented Feb 17, 2024

I figured this out this problem and, until this gets fixed, the only workaround is to override the types yourself. I did this by importing the types itself and extending it to an interface then wrapping it with a Partial generic works.

Here's a hack I've haphazardly implemented of getting most the types to be optional in Next.js:

"use client"

import dynamic from "next/dynamic"
import type { IEventProps, IFlipSetting } from "react-pageflip/build/html-flip-book/settings"

interface HTMLFilpPageOverride extends Partial<IFlipSetting & IEventProps> {
  className?: string
  style?: React.CSSProperties
  children: React.ReactNode
  renderOnlyPageLengthChange?: boolean
  ref?: any
}

const HTMLFlipBook = dynamic(() => import("react-pageflip"), {
  ssr: false
}) as React.ComponentType<HTMLFilpPageOverride>

export default function BookWrapper() {
  return (
    <HTMLFlipBook width={300} height={500}>
      <div className="demoPage">Page 1</div>
      <div className="demoPage">Page 2</div>
      <div className="demoPage">Page 3</div>
      <div className="demoPage">Page 4</div>
    </HTMLFlipBook>
  )
}

@bstevary
Copy link

since 2022, no one has close this issue, it should be marked as a bug. I have been force several time to follow what typescript need

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants