-
Notifications
You must be signed in to change notification settings - Fork 21
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
Add TS Def file #2
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I make some considerations about the TypeScript definition here. please, consider it.
script?: string; | ||
minSpreadWidth?: number; | ||
gap?: number; | ||
onPress?(ev: object): void; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
onPress must receive other props and not a event object. See the file: https://github.com/ottofeller/epubjs-rn/blob/master/src/Rendition.js#L346
case "press": {
this.props.onPress && this.props.onPress(decoded.cfi, decoded.position, this);
break;
}
The correct props to ts definition file must be:
onPress?(cfi: string, position {x: number; y: number;}, rendition: Rendition): void;
But, now, we have a potential problem: in this definition, we not have a exported Rendition (as interface or as Component).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And, complementing, the Epub component onPress event is parsed directly to the Rendition component, then, to see better the props of the Epub, is needed to see the behaviour of the Rendition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same occur to other events in those TypeScript definitions.
onLocationsReady?(): void; | ||
onViewAdded?(): void; | ||
beforeViewRemoved?(): void; | ||
width: number; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The width (and the height properties is not required by the Epub component).
declare module '@ottofeller/epubjs-rn' { | ||
import React from 'react'; | ||
|
||
interface Props { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The onError event is not defined in the props.
import React from 'react'; | ||
|
||
interface Props { | ||
style?: object; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is style is the react-native style? If positive, consider that changing this from object to real style definition, like StyleProp<ViewStyle>
for the View
component.
No description provided.