mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-02-24 14:13:05 +01:00
22 lines
449 B
JavaScript
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 };
|
|
}
|