Skip to content

Importing cryptoRandomString from deno.land doesn't work #4

@osilkin98

Description

@osilkin98

I'm trying to put together a simple todo app with Deno and am running into an issue where calling crytpoRandomString causes the page to crash without outputting any meaningful error.

The code:

// ..
import { cryptoRandomString } from "https://deno.land/x/[email protected]/mod.ts";

type Props = React.ComponentProps<typeof useDeno>;

type Task = {
  id: string;
  data: string;
};

export default function Home<Props>() {
  const [tasks, setTasks] = useState([] as Task[]);
  const [task, setTask] = useState("");

  const handleAddTask = (e: any) => {
    const newTask: Task = {
      id: cryptoRandomString({
        length: 16,
        type: "abc",
      }),
      data: task,
    };
    setTasks([...tasks, newTask]);
    setTask("");
  };

  // .. 

  return (
   // .. 
   <button onClick={handleAddTask}>Add Task</button>
   // .. 
  );
}

I'm not quite sure why this is happening, but aleph isn't erroring out at the commandline, so this must be some issue with the crypto-random-string lib.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions