Skip to content

Commit 2afcf58

Browse files
authored
Merge pull request #35 from thinknimble/fix/remove-rn-uuid
Remove react-native-uuid
2 parents 4abd7ea + 07f688c commit 2afcf58

6 files changed

Lines changed: 12 additions & 24 deletions

File tree

.changeset/silver-shirts-smell.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@thinknimble/tn-forms': patch
3+
---
4+
5+
Fix issue with uuid - remove it and use timestamp ms instead

dist/index.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,6 @@ __export(index_exports, {
5757
});
5858
module.exports = __toCommonJS(index_exports);
5959

60-
// src/forms.ts
61-
var import_react_native_uuid = __toESM(require("react-native-uuid"));
62-
6360
// src/utils.ts
6461
function notNullOrUndefined(value) {
6562
return value !== null && typeof value !== "undefined";
@@ -130,12 +127,12 @@ var FormField = class _FormField {
130127
label = ""
131128
} = {}) {
132129
this.value = Array.isArray(value) ? [...value] : value !== null && typeof value == "object" ? { ...value } : value === void 0 ? "" : value;
133-
this.name = name ? name : import_react_native_uuid.default.v4();
130+
this.name = name ? name : String(Date.now());
134131
this.errors = errors;
135132
this.validators = validators;
136133
this.placeholder = placeholder;
137134
this.type = type;
138-
this.id = id ? id : name ? name : "field-" + import_react_native_uuid.default.v4();
135+
this.id = id ? id : name ? name : "field-" + String(Date.now());
139136
this._isTouched = isTouched;
140137
this.label = label;
141138
}

dist/index.mjs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
// src/forms.ts
2-
import uuid from "react-native-uuid";
3-
41
// src/utils.ts
52
function notNullOrUndefined(value) {
63
return value !== null && typeof value !== "undefined";
@@ -71,12 +68,12 @@ var FormField = class _FormField {
7168
label = ""
7269
} = {}) {
7370
this.value = Array.isArray(value) ? [...value] : value !== null && typeof value == "object" ? { ...value } : value === void 0 ? "" : value;
74-
this.name = name ? name : uuid.v4();
71+
this.name = name ? name : String(Date.now());
7572
this.errors = errors;
7673
this.validators = validators;
7774
this.placeholder = placeholder;
7875
this.type = type;
79-
this.id = id ? id : name ? name : "field-" + uuid.v4();
76+
this.id = id ? id : name ? name : "field-" + String(Date.now());
8077
this._isTouched = isTouched;
8178
this.label = label;
8279
}

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@
3434
"email-validator": "^2.0.4",
3535
"install": "^0.13.0",
3636
"libphonenumber-js": "^1.11.11",
37-
"luxon": "^2.4.0",
38-
"react-native-uuid": "^2.0.1"
37+
"luxon": "^2.4.0"
3938
},
4039
"devDependencies": {
4140
"@types/luxon": "^3.0.0",

pnpm-lock.yaml

Lines changed: 0 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/forms.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import {
1717
TFormInstanceFields,
1818
} from './interfaces'
1919

20-
import uuid from 'react-native-uuid'
2120
import { isFormArray, isFormField } from './utils'
2221

2322
function setFormFieldValueFromKwargs<T, TName extends string = ''>(
@@ -79,12 +78,12 @@ export class FormField<T = string, TName extends string = ''> implements IFormFi
7978
? ''
8079
: value
8180
) as T
82-
this.name = (name ? name : (uuid.v4() as string)) as TName
81+
this.name = (name ? name : (String(Date.now()))) as TName
8382
this.errors = errors
8483
this.validators = validators
8584
this.placeholder = placeholder
8685
this.type = type
87-
this.id = id ? id : name ? name : 'field' + '-' + uuid.v4()
86+
this.id = id ? id : name ? name : 'field' + '-' + String(Date.now())
8887
this._isTouched = isTouched
8988
this.label = label
9089
}

0 commit comments

Comments
 (0)