Skip to content

Commit

Permalink
Remove extra util file
Browse files Browse the repository at this point in the history
It is not necessary.
  • Loading branch information
Arnei committed May 28, 2024
1 parent 36b5d2f commit 2957ec5
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/confirmationModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
useImperativeHandle,
} from "react";
import { ModalProps, ModalHandle, Modal, Spinner, Button, boxError } from ".";
import { currentRef } from "./utilFunc";
import { currentRef } from "./util";


type ConfirmationModalProps = Omit<ModalProps, "closable" | "title"> & {
Expand Down
1 change: 0 additions & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export * from "./floating";
export * from "./header";
export * from "./spinner";
export * from "./util";
export * from "./utilFunc";
export * from "./modal";
export * from "./styledButton";

Expand Down
11 changes: 11 additions & 0 deletions src/util.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { MutableRefObject, useEffect } from "react";
import { bug } from "./err";

/**
* A switch-case-like expression with exhaustiveness check (or fallback value).
Expand Down Expand Up @@ -69,3 +70,13 @@ export const useOnOutsideClick = (
return () => document.removeEventListener("mousedown", handler);
});
};

/**
* Accesses the current value of a ref, signaling an error when it is unbound.
* Note: **Don't** use this if you expect the ref to be unbound temporarily.
* This is mainly for accessing refs in event handlers for elements
* that are guaranteed to be alive as long as the ref itself.
*/
export const currentRef = <T, >(ref: React.RefObject<T>): T => (
ref.current ?? bug("ref unexpectedly unbound")
);
12 changes: 0 additions & 12 deletions src/utilFunc.ts

This file was deleted.

0 comments on commit 2957ec5

Please sign in to comment.