cinny/src/app/hooks/useStore.js
Ajay Bura 38cbb87a62 Added unread indicator (#67), reply link back to original (#96)
Signed-off-by: Ajay Bura <ajbura@gmail.com>
2021-12-03 18:32:10 +05:30

22 lines
449 B
JavaScript

/* eslint-disable import/prefer-default-export */
import { useEffect, useRef } from 'react';
export function useStore(...args) {
const itemRef = useRef(null);
const getItem = () => itemRef.current;
const setItem = (event) => {
itemRef.current = event;
return itemRef.current;
};
useEffect(() => {
itemRef.current = null;
return () => {
itemRef.current = null;
};
}, args);
return { getItem, setItem };
}