Skip to content

Commit

Permalink
test to read file
Browse files Browse the repository at this point in the history
  • Loading branch information
gloryvictory committed Nov 14, 2022
1 parent a35b3d9 commit eaefc9a
Show file tree
Hide file tree
Showing 2 changed files with 143 additions and 1 deletion.
129 changes: 129 additions & 0 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 14 additions & 1 deletion islands/Counter.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
import { useState } from "preact/hooks";
import { Button } from "../components/Button.tsx";
// import fs from 'fs'

interface CounterProps {
start: number;
}

export default function Counter(props: CounterProps) {
export default function Counter(props: CounterProps) {
const [count, setCount] = useState(props.start);

const testJsonFile = async () => {
const file1 = await Deno.open("../data/lu.json", { read: true });

// let dataArray = JSON.parse(file1.read())
console.log(file1)

}


return (
<div class="flex gap-2 w-full">
<p class="flex-grow-1 font-bold text-xl">{count}</p>
<Button onClick={() => setCount(count - 1)}>-1</Button>
<Button onClick={() => setCount(count + 1)}>+1</Button>
<Button onClick={testJsonFile}>test </Button>

</div>
);
}

0 comments on commit eaefc9a

Please sign in to comment.