Skip to content

Commit

Permalink
fix: remove uuid library (#472)
Browse files Browse the repository at this point in the history
Replaced uuid lib with react.useId
  • Loading branch information
matttdawson authored Sep 2, 2024
1 parent cda7b51 commit 41c0b79
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 26 deletions.
19 changes: 3 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@
"lodash-es": ">=4",
"matcher": "^5.0.0",
"react-transition-state": "^2.1.2",
"usehooks-ts": "^3.1.0",
"uuid": "^10.0.0"
"usehooks-ts": "^3.1.0"
},
"scripts": {
"build": "run-s clean stylelint lint css bundle",
Expand Down
11 changes: 3 additions & 8 deletions src/lui/TextAreaInput.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
import clsx from "clsx";
import { omit } from "lodash-es";
import { InputHTMLAttributes, ReactElement, useState } from "react";
import { v4 as uuidVersion4 } from "uuid";
import { InputHTMLAttributes, ReactElement, useId } from "react";

import { FormError } from "./FormError";

export const useGenerateOrDefaultId = (idFromProps?: string) => {
const [id] = useState(idFromProps ? idFromProps : uuidVersion4());
return id;
};

export interface LuiTextAreaInputProps extends InputHTMLAttributes<HTMLTextAreaElement> {
// overrides value in base class to be string type only
value: string;
Expand All @@ -23,7 +17,8 @@ export interface LuiTextAreaInputProps extends InputHTMLAttributes<HTMLTextAreaE
}

export const TextAreaInput = (props: LuiTextAreaInputProps) => {
const id = useGenerateOrDefaultId(props?.id);
const reactId = useId();
const id = props?.id ?? reactId;

return (
<div
Expand Down

0 comments on commit 41c0b79

Please sign in to comment.