Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
osilkin98 opened this issue Jan 18, 2022 · 1 comment
Open

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

osilkin98 opened this issue Jan 18, 2022 · 1 comment

Comments

@osilkin98
Copy link

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.

@osilkin98
Copy link
Author

Update:
This works:

import { cryptoRandomString } from "https://github.com/piyush-bhatt/crypto-random-string/raw/main/mod.ts";

This doesn't:

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

@osilkin98 osilkin98 changed the title crypto-random-string breaking webpage Importing cryptoRandomString from deno.land doesn't work Jan 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant