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 authored Oct 21, 2023
1 parent 01deaf8 commit e8cc9ae
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 8 deletions.
3 changes: 3 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
"recommended": true,
"correctness": {
"noUnusedVariables": "warn"
},
"suspicious": {
"noExplicitAny": "off"
}
}
},
Expand Down
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
4 changes: 2 additions & 2 deletions 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 = any> = {
/**
* Target React element ref.
*/
Expand Down Expand Up @@ -46,7 +46,7 @@ export type UseOnScreenParameters<T extends HTMLElement = HTMLElement> = {
* @param {UseOnScreenParameters} useOnScreenParameters - Parameters.
* @returns .
*/
export const useOnScreen = <T extends HTMLElement>({
export const useOnScreen = <T extends HTMLElement = any>({
ref,
threshold = 0,
once = false,
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 e8cc9ae

Please sign in to comment.