mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 12:56:41 +07:00
refactored hooks directory
This commit is contained in:
parent
efa3ba902d
commit
f76a5a4798
106 changed files with 122 additions and 144 deletions
|
@ -1,24 +0,0 @@
|
|||
import { useCallback } from 'react';
|
||||
import { flowChangeSearch, flowLoadMoreSearch } from '~/redux/flow/actions';
|
||||
import { useDispatch } from 'react-redux';
|
||||
import { useShallowSelect } from '~/utils/hooks/useShallowSelect';
|
||||
import { selectFlow } from '~/redux/flow/selectors';
|
||||
|
||||
export const useSearch = () => {
|
||||
const dispatch = useDispatch();
|
||||
const { search } = useShallowSelect(selectFlow);
|
||||
|
||||
const onSearchLoadMore = useCallback(() => {
|
||||
if (search.is_loading_more) return;
|
||||
dispatch(flowLoadMoreSearch());
|
||||
}, [search.is_loading_more, dispatch]);
|
||||
|
||||
const onSearchChange = useCallback(
|
||||
(text: string) => {
|
||||
dispatch(flowChangeSearch({ text }));
|
||||
},
|
||||
[dispatch]
|
||||
);
|
||||
|
||||
return { onSearchChange, onSearchLoadMore, search };
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue