mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-04 00:18:01 +01:00
* chore: update changelog * chore: update changelog * fix: refactor AddUser * feat: add screens for email and copy * fix: remove interface * fix: admin constant in userlist * chore: fix changelog * feat: user data fetching with useSWR * feat: flesh out dialogues * fix: remove useRequest * refactor: remove redux for user admin * refactor: remove from store * refactor: userListItem * fix: change type * feat: add initial loading * fix: useLayoutEffeect in useLoading * fix: remove useEffect * fix: update snapshots * fix: remove status code * fix: remove roles from store
25 lines
632 B
TypeScript
25 lines
632 B
TypeScript
import { createRef, useLayoutEffect } from 'react';
|
|
|
|
type refElement = HTMLDivElement;
|
|
|
|
const useLoading = (loading: boolean) => {
|
|
const ref = createRef<refElement>();
|
|
useLayoutEffect(() => {
|
|
if (ref.current) {
|
|
const elements = ref.current.querySelectorAll('[data-loading]');
|
|
|
|
elements.forEach(element => {
|
|
if (loading) {
|
|
element.classList.add('skeleton');
|
|
} else {
|
|
element.classList.remove('skeleton');
|
|
}
|
|
});
|
|
}
|
|
}, [loading, ref]);
|
|
|
|
return ref;
|
|
};
|
|
|
|
export default useLoading;
|