-
Notifications
You must be signed in to change notification settings - Fork 32
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
Create index.d.ts #149
base: master
Are you sure you want to change the base?
Create index.d.ts #149
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.
Thanks a lot for your contribution @Palid! I do have a few remarks and questions.
@@ -0,0 +1,48 @@ | |||
import React from 'react' | |||
import { ReactNode } from 'react'; |
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 believe that this import is obsolete since you are only accessing ReactNode
via React
a few lines below.
export class ViewportAwarePlaceholder extends React.Component<ViewportAwarePlaceholderProps> {} | ||
|
||
|
||
|
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.
It would be great if you can unify the number of blank lines between the code blocks in the file. There are a total of 3 here and a total of 2 at line 9. One blank line is enough. Ideally, we should have TSLint setup, but that is not absolutely necessary at the moment.
import { ReactNode } from 'react'; | ||
|
||
export interface ViewportTrackerProps { | ||
children: React.ReactNode |
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.
tabWidth
is set to 2 for JS files. It would be great if we can stick to the same for this file as well.
|
||
export interface ViewportAwareComponentProps { | ||
/** | ||
* Determines pre-triggering of inViewport. Useful for rendering components beforehand to improve user experience. A ratio of 0.5 means that the effective viewport will be twice the size of the real viewport. |
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 comment should probably be split into several lines.
export const Viewport = { | ||
Tracker: ViewportTracker, | ||
Aware: (component: typeof React.Component) => ViewportAware, | ||
WithPlaceholder: (image: React.Component, placeholder: React.Component) => ViewportAwarePlaceholder |
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 wrapped component can be something other than image as well, so I would replace image
with component
. Also, the placeholder argument should be optional.
|
||
export const Viewport = { | ||
Tracker: ViewportTracker, | ||
Aware: (component: typeof React.Component) => ViewportAware, |
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.
Is typeof
necessary and if so, why isn't it used one line below, for the WithPlaceholder
HoC as well?
*/ | ||
innerRef?: React.Ref | ||
} | ||
export class ViewportAware<P> extends React.Component<ViewportAwareComponentProps & P> {} |
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.
Why are all of the classes and interfaces exported? Isn't the const Viewport
export at the bottom sufficient?
No description provided.