Question · Vibe coding with Claude Code course · Module 12: Medium clone

Block identifiers

Why does newBlock in the chronicle editor give a block an id from crypto.randomUUID() and not from Date.now().toString()?

Answer options

  • crypto.randomUUID() is shorter, so it is quicker to type in code
  • Blocks created in the same millisecond would get the same number from Date.now(), and two blocks with one id change together
  • Date.now() works only on the server, and the editor runs in the browser
  • React accepts only strings 36 characters long as a key

You can check the correct answer by solving this task in the CodeWorlds game.