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

Add TS Def file #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

aprofromindia
Copy link

No description provided.

Copy link

@EduardoJM EduardoJM left a 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;

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).

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.

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;

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 {

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;

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.

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

Successfully merging this pull request may close these issues.

2 participants