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

Allow to use OnScreen without specifying html element type #19

Merged
merged 3 commits into from
Oct 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading