Skip to content

Commit

Permalink
allow to use OnScreen without specifying html element type #12
Browse files Browse the repository at this point in the history
  • Loading branch information
ukorvl committed Oct 21, 2023
1 parent 01deaf8 commit ea5d8b1
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions lib/OnScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { UseOnScreenParameters, useOnScreen } from "./useOnScreen";
/**
* OnScreen component own props.
*/
type OnScreenOwnProps<T extends HTMLElement, AS extends ElementType = ElementType> = {
type OnScreenOwnProps<T extends HTMLElement = any, AS extends ElementType = ElementType> = {
/**
* Render function.
*/
Expand All @@ -27,7 +27,7 @@ type OnScreenOwnProps<T extends HTMLElement, AS extends ElementType = ElementTyp
* OnScreen component props with generic element props.
*/
export type OnScreenProps<
T extends HTMLElement,
T extends HTMLElement = any,
AS extends ElementType = ElementType,
> = OnScreenOwnProps<T, AS> & Omit<ComponentProps<AS>, keyof OnScreenOwnProps<T, AS>>;

Expand All @@ -46,7 +46,7 @@ export type OnScreenProps<
* @param {OnScreenProps} onScreenComponentProps Props.
* @returns Children elements with on-screen wrapper.
*/
export const OnScreen = <T extends HTMLElement, AS extends ElementType = ElementType>({
export const OnScreen = <T extends HTMLElement = any, AS extends ElementType = ElementType>({
children,
margin,
threshold,
Expand Down
2 changes: 1 addition & 1 deletion lib/useOnScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { RefObject, useEffect, useState } from "react";
/**
* UseOnScreen hook settings.
*/
export type UseOnScreenParameters<T extends HTMLElement = HTMLElement> = {
export type UseOnScreenParameters<T extends HTMLElement> = {
/**
* Target React element ref.
*/
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ukorvl/react-on-screen",
"version": "1.0.5",
"version": "1.0.6",
"description": "Lightweight typescript library to detect React elements visibility",
"license": "MIT",
"author": "ukorvl",
Expand Down

0 comments on commit ea5d8b1

Please sign in to comment.