fix render issue

This commit is contained in:
h z
2024-12-03 16:36:32 +00:00
parent 22da3bc90d
commit 18a84123d3
8 changed files with 38 additions and 10 deletions

View File

@@ -13,7 +13,7 @@ const MainNavigation = () => {
<li>
<Link to="/">Home</Link>
</li>
{user ? (
{ user && user.profile ? (
<div>
<h1>{user.profile.name}</h1>
<button onClick={logout}>Logout</button>

View File

@@ -3,7 +3,7 @@
import React, { useEffect, useState } from "react";
import { useParams } from "react-router-dom";
import {fetchWithCache} from "../utils/fetchWIthCache";
import {fetchWithCache} from "../utils/fetchWithCache";
const MarkdownContent = () => {
const { id } = useParams();

View File

@@ -3,14 +3,14 @@
import React, { useEffect, useState } from "react";
import { Link } from "react-router-dom";
import "./SideNavigation.css";
import { fetchWithCache } from "../utils/fetchWithCache";
import {fetchWithCache} from "../utils/fetchWithCache";
const SideNavigation = () => {
const [markdowns, setMarkdowns] = useState([]);
const [tree, setTree] = useState(null);
useEffect(() => {
fetchWithCache("/api/markdown/")
fetchWithCache("http://127.0.0.1:5000/api/markdown/")
.then((data) => {
setMarkdowns(data);
setTree(buildTree(data));
@@ -44,7 +44,7 @@ const SideNavigation = () => {
if (value.markdown) {
return (
<li key={value.markdown.id}>
<Link to={`/markdown/${value.markdown.id}`}>
<Link to={`http://127.0.0.1:5000/markdown/${value.markdown.id}`}>
{value.markdown.title}
</Link>
</li>