v1功能在React Native Expo中不起作用?

huangapple go评论68阅读模式
英文:

v1 function for uuid not working for react native expo?

问题

我有以下的代码:

const handlefb = async () => {
    const fb = sRef(storage, `paramKey/${feedback + v1()}`);
    uploadString(fb, todoDatafb).then((snapshot) => {
      console.log('Uploaded new feedback')
    })

根据 https://www.npmjs.com/package/uuid,v1 用于“创建版本 1 (时间戳) UUID”。但它并没有为我生成时间戳。

参考文件的截图:

v1功能在React Native Expo中不起作用?

为什么会这样?我是不是在错误地使用这个函数?

英文:

I have the following code:

const handlefb = async () => {
    const fb = sRef(storage, `paramKey/${feedback + v1()}`);
    uploadString(fb, todoDatafb).then((snapshot) => {
      console.log('Uploaded new feedback')
    })

According to https://www.npmjs.com/package/uuid, v1 is for Create a version 1 (timestamp) UUID. But it does not generate a timestamp for me.

Refer to screenshot of the file:

v1功能在React Native Expo中不起作用?

How come? Am I using the function wrongly?

答案1

得分: 1

函数正常运行。它正在生成一个 UUID。v1 不生成时间戳,它生成基于时间的 UUID。如果您需要时间戳,只需使用 JavaScript 的 Date 对象。

英文:

The function is working as expected. It's generating a uuid. v1 does not generate a timestamp, it generates a time-based uuid. If you want a timestamp, just use the JavaScript Date object.

huangapple
  • 本文由 发表于 2023年3月9日 16:52:54
  • 转载请务必保留本文链接:https://go.coder-hub.com/75682275.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定