From 4243b4f21350e5281dd686a37f40e4e25d7b9abc Mon Sep 17 00:00:00 2001 From: Imbus Date: Mon, 13 Nov 2023 11:50:24 +0100 Subject: [PATCH] Better state management --- client-solid/src/Navbar.tsx | 45 +++++++++++++++----------- client-solid/src/NewPost.tsx | 56 ++++++++++++++++++++++++++++++++ client-solid/src/Posts.tsx | 2 +- client-solid/src/Primary.tsx | 2 +- client-solid/src/Root.tsx | 62 ++---------------------------------- 5 files changed, 87 insertions(+), 80 deletions(-) create mode 100644 client-solid/src/NewPost.tsx diff --git a/client-solid/src/Navbar.tsx b/client-solid/src/Navbar.tsx index c4485b8..8e9285d 100644 --- a/client-solid/src/Navbar.tsx +++ b/client-solid/src/Navbar.tsx @@ -1,9 +1,10 @@ -import { useContext } from "solid-js"; +import { JSXElement, createEffect, createSignal, useContext } from "solid-js"; import { A } from "@solidjs/router"; import { LoginContext } from "./Root"; import { ModalContext } from "./Root"; -function MenuItem(props: { href: string; children: any }) { +// Represents a single list item in the menu bar +function MenuItem(props: { href: string; children: JSXElement }) { return (
  • @@ -13,8 +14,9 @@ function MenuItem(props: { href: string; children: any }) { ); } +// Represents the menu bar at the top of the page function Menu() { - let login_ctx = useContext(LoginContext); + const login_ctx = useContext(LoginContext); return (