Skip to content

Commit

Permalink
fix: kick out nanoid
Browse files Browse the repository at this point in the history
  • Loading branch information
lordspace74 committed Mar 27, 2023
1 parent 335b7b0 commit 9713341
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 18 deletions.
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
"@storybook/testing-library": "^0.0.13",
"@testing-library/react-hooks": "^8.0.1",
"@types/jest": "^28.1.4",
"@types/nanoid": "^3.0.0",
"@types/node": "^18.7.8",
"@types/react": "18",
"@types/react-native": "0.69",
Expand Down Expand Up @@ -130,7 +129,6 @@
},
"dependencies": {
"@gorhom/portal": "^1.0.14",
"nanoid": "^4.0.0",
"ts-pattern": "^4.0.5",
"urql": ">=2",
"zustand": "^4.3.6"
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/useUpdateSharedPortalAreaInsets.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { nanoid } from 'nanoid'
import { useEffect } from 'react'

import generateId from '../utils/generateId'
import useSharedPortalAreaStore from './useSharedPortalAreaStore'

import type { Insets } from 'react-native'
Expand All @@ -12,7 +12,7 @@ export const useUpdateSharedPortalAreaInsets = (insets: Required<Insets>, enable

useEffect(() => {
if (enable) {
const id = nanoid()
const id = generateId()
pushInset({ ...insets, id })
return () => removeInset(id)
}
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/useUpdateSharedPortalSafeAreaInsets.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { nanoid } from 'nanoid'
import { useEffect } from 'react'
import { useSafeAreaInsets } from 'react-native-safe-area-context'

import generateId from '../utils/generateId'
import useSharedPortalAreaStore from './useSharedPortalAreaStore'

import type { Insets } from 'react-native'
Expand All @@ -16,7 +16,7 @@ export const useUpdateSharedPortalSafeAreaInsets = (insets: Insets, enable = tru

useEffect(() => {
if (enable) {
const id = nanoid()
const id = generateId()
pushInset({ ...safeAreaInsets, ...insets, id })
return () => removeInset(id)
}
Expand Down
11 changes: 11 additions & 0 deletions src/utils/generateId.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export default function generateId(length = 10) {
const characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
let result = ''

for (let i = 0; i < length; i += 1) {
const randomIndex = Math.floor(Math.random() * characters.length)
result += characters[randomIndex]
}

return result
}
12 changes: 0 additions & 12 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4068,13 +4068,6 @@
resolved "https://registry.yarnpkg.com/@types/minimist/-/minimist-1.2.2.tgz#ee771e2ba4b3dc5b372935d549fd9617bf345b8c"
integrity sha512-jhuKLIRrhvCPLqwPcx6INqmKeiA5EWrsCOPhrlFSrbrmU4ZMPjj5Ul/oLCMDO98XRUIwVm78xICz4EPCektzeQ==

"@types/nanoid@^3.0.0":
version "3.0.0"
resolved "https://registry.yarnpkg.com/@types/nanoid/-/nanoid-3.0.0.tgz#c757b20f343f3a1dd76e80a9a431b6290fc20f35"
integrity sha512-UXitWSmXCwhDmAKe7D3hNQtQaHeHt5L8LO1CB8GF8jlYVzOv5cBWDNqiJ+oPEWrWei3i3dkZtHY/bUtd0R/uOQ==
dependencies:
nanoid "*"

"@types/node-fetch@^2.5.7":
version "2.6.2"
resolved "https://registry.yarnpkg.com/@types/node-fetch/-/node-fetch-2.6.2.tgz#d1a9c5fd049d9415dce61571557104dec3ec81da"
Expand Down Expand Up @@ -13404,11 +13397,6 @@ nan@^2.12.1:
resolved "https://registry.yarnpkg.com/nan/-/nan-2.16.0.tgz#664f43e45460fb98faf00edca0bb0d7b8dce7916"
integrity sha512-UdAqHyFngu7TfQKsCBgAA6pWDkT8MAO7d0jyOecVhN5354xbLqdn8mV9Tat9gepAupm0bt2DbeaSC8vS52MuFA==

nanoid@*, nanoid@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-4.0.0.tgz#6e144dee117609232c3f415c34b0e550e64999a5"
integrity sha512-IgBP8piMxe/gf73RTQx7hmnhwz0aaEXYakvqZyE302IXW3HyVNhdNGC+O2MwMAVhLEnvXlvKtGbtJf6wvHihCg==

nanoid@^3.1.23, nanoid@^3.3.1:
version "3.3.4"
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.4.tgz#730b67e3cd09e2deacf03c027c81c9d9dbc5e8ab"
Expand Down

0 comments on commit 9713341

Please sign in to comment.