moved hooks to global folder

This commit is contained in:
Bernt Christian Egeland 2021-08-29 11:30:09 +02:00
parent 427de19e1a
commit 8def3f9198
4 changed files with 5 additions and 5 deletions

View File

@ -1,7 +1,7 @@
import { useEffect, useRef } from 'preact/hooks'; import { useEffect, useRef } from 'preact/hooks';
// https://stackoverflow.com/a/54292872/2693528 // https://stackoverflow.com/a/54292872/2693528
export const useOuterClick = (callback) => { export const useClickOutside = (callback) => {
const callbackRef = useRef(); // initialize mutable ref, which stores callback const callbackRef = useRef(); // initialize mutable ref, which stores callback
const innerRef = useRef(); // returned to client, who marks "border" element const innerRef = useRef(); // returned to client, who marks "border" element

View File

@ -4,8 +4,8 @@ import { useCallback, useState, useMemo } from 'preact/hooks';
import { Tr, Td, Tbody } from '../../../components/Table'; import { Tr, Td, Tbody } from '../../../components/Table';
import Filterable from './filterable'; import Filterable from './filterable';
import Event from '../../Event'; import Event from '../../Event';
import { useSearchString } from '../hooks/useSearchString'; import { useSearchString } from '../../../hooks/useSearchString';
import { useOuterClick } from '../hooks/useClickOutside'; import { useClickOutside } from '../../../hooks/useClickOutside';
const EventsRow = memo( const EventsRow = memo(
({ ({
@ -27,7 +27,7 @@ const EventsRow = memo(
const { searchString, removeDefaultSearchKeys } = useSearchString(limit); const { searchString, removeDefaultSearchKeys } = useSearchString(limit);
const searchParams = useMemo(() => new URLSearchParams(searchString), [searchString]); const searchParams = useMemo(() => new URLSearchParams(searchString), [searchString]);
const innerRef = useOuterClick(() => { const innerRef = useClickOutside(() => {
setViewEvent(null); setViewEvent(null);
}); });

View File

@ -7,7 +7,7 @@ import { FetchStatus, useApiHost, useEvents } from '../../api';
import { Table, Tfoot, Tr, Td } from '../../components/Table'; import { Table, Tfoot, Tr, Td } from '../../components/Table';
import { useCallback, useEffect, useMemo, useReducer } from 'preact/hooks'; import { useCallback, useEffect, useMemo, useReducer } from 'preact/hooks';
import { reducer, initialState } from './reducer'; import { reducer, initialState } from './reducer';
import { useSearchString } from './hooks/useSearchString'; import { useSearchString } from '../../hooks/useSearchString';
import { useIntersectionObserver } from '../../hooks'; import { useIntersectionObserver } from '../../hooks';
const API_LIMIT = 25; const API_LIMIT = 25;