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

[test]: useHover #84

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

wmoooid
Copy link
Contributor

@wmoooid wmoooid commented May 28, 2024

сделал тесты для useHover
closes #37

@wmoooid
Copy link
Contributor Author

wmoooid commented May 28, 2024

@debabin когда писал тест пришлось перекрывать тип рефа, иначе тс ругался. Кажется, с этим надо что-то сделать.

const MockComponent = () => {
      const [ref, isHovering] = useHover({});

      return (
        <div data-testid='target' ref={ref as React.RefObject<HTMLDivElement>}>
          {isHovering ? 'true' : 'false'}
        </div>
      );
    };

Текст ошибки:

Type 'RefObject' is not assignable to type 'LegacyRef | undefined'.
Type 'RefObject' is not assignable to type 'RefObject'.
Type 'UseHoverTarget' is not assignable to type 'HTMLDivElement'.
Type 'Element' is missing the following properties from type 'HTMLDivElement': align, accessKey, accessKeyLabel, autocapitalize, and 124 more.ts(2322)
index.d.ts(303, 9): The expected type comes from property 'ref' which is declared here on type 'DetailedHTMLProps<HTMLAttributes, HTMLDivElement>'

@str0yka
Copy link
Contributor

str0yka commented Jun 3, 2024

@wmoooid в useHover надо просто дженерик прокинуть useHover<HTMLDivElement>
Надо бы обновить пример в описание хука @debabin

@debabin
Copy link
Member

debabin commented Jun 3, 2024

@wmoooid в useHover надо просто дженерик прокинуть useHover<HTMLDivElement> Надо бы обновить пример в описание хука @debabin

Пример для js кода, а generic это дефалт для useRef и тут тоже самое

@wmoooid wmoooid closed this Jun 4, 2024
@wmoooid wmoooid force-pushed the test-useHover-main branch from 41fa177 to ede017d Compare June 4, 2024 09:51
@wmoooid wmoooid reopened this Jun 4, 2024
@wmoooid
Copy link
Contributor Author

wmoooid commented Jun 4, 2024

@wmoooid в useHover надо просто дженерик прокинуть useHover<HTMLDivElement>

@str0yka Да, спасибо, не заметил, что тип можно прокинуть

@wmoooid
Copy link
Contributor Author

wmoooid commented Jun 4, 2024

@debabin переделал тесты, посмотри пожалуйста

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.

[test]: Описать тесты для хука useHover
3 participants