mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 12:56:41 +07:00
#35 refactored node layout
This commit is contained in:
parent
428c7e7a06
commit
d3473eab4c
20 changed files with 406 additions and 344 deletions
17
src/utils/hooks/node/useNodeCoverImage.ts
Normal file
17
src/utils/hooks/node/useNodeCoverImage.ts
Normal file
|
@ -0,0 +1,17 @@
|
|||
import { INode } from '~/redux/types';
|
||||
import { useEffect } from 'react';
|
||||
import { useDispatch } from 'react-redux';
|
||||
import { nodeSetCoverImage } from '~/redux/node/actions';
|
||||
|
||||
export const useNodeCoverImage = (node: INode) => {
|
||||
const dispatch = useDispatch();
|
||||
|
||||
useEffect(() => {
|
||||
if (!node.cover) return;
|
||||
dispatch(nodeSetCoverImage(node.cover));
|
||||
|
||||
return () => {
|
||||
nodeSetCoverImage(undefined);
|
||||
};
|
||||
}, [dispatch, node.cover]);
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue