mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-11-06 15:30:27 +03:00
Signed-off-by: Ajay Bura <ajbura@gmail.com>
This commit is contained in:
parent
0c0a978886
commit
38cbb87a62
21 changed files with 948 additions and 507 deletions
8
src/app/hooks/useForceUpdate.js
Normal file
8
src/app/hooks/useForceUpdate.js
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
/* eslint-disable import/prefer-default-export */
|
||||
import { useState } from 'react';
|
||||
|
||||
export function useForceUpdate() {
|
||||
const [, setData] = useState(null);
|
||||
|
||||
return () => setData({});
|
||||
}
|
||||
22
src/app/hooks/useStore.js
Normal file
22
src/app/hooks/useStore.js
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
/* 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 };
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue