Skip to content

Commit

Permalink
refac: use context for ws
Browse files Browse the repository at this point in the history
  • Loading branch information
almahdi404 committed Sep 9, 2024
1 parent 89494d1 commit db8cd23
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
5 changes: 2 additions & 3 deletions src/components/Nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { AppContext } from "~/components/TreeGround";
import { getBaseName, sendMsgToServer } from "~/utils";

const Nav: Component<{
ws: Accessor<WebSocket | null>;
grammars: Accessor<TsGrammar[]>;
setGrammars: Setter<TsGrammar[]>;
selectedGrammar: Accessor<string | undefined>;
Expand All @@ -41,7 +40,7 @@ const Nav: Component<{
e.preventDefault();
const inputGrmr = inputGrammar();
if (inputGrmr) {
const socket = props.ws();
const socket = ctx.ws();
if (socket) {
sendMsgToServer(socket, {
type: "add",
Expand All @@ -63,7 +62,7 @@ const Nav: Component<{

const removeGrammar = (e: Event) => {
e.preventDefault();
const socket = props.ws();
const socket = ctx.ws();
const selectedGrmr = props.selectedGrammar();
if (socket && selectedGrmr) {
sendMsgToServer(socket, {
Expand Down
1 change: 0 additions & 1 deletion src/components/TreeGround.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ function App() {
<AppContext.Provider value={{ modal, setModal, ws }}>
<div class="p-2">
<Nav
ws={ws}
grammars={grammars}
setGrammars={setGrammars}
selectedGrammar={selectedGrammar}
Expand Down

0 comments on commit db8cd23

Please sign in to comment.