rerender issue

This commit is contained in:
e560248
2025-04-07 11:04:20 +02:00
parent 08e2459408
commit 88af8b80cc
4 changed files with 17 additions and 0 deletions

View File

@@ -1,4 +1,5 @@
function Footer() { function Footer() {
console.log("Footer rendered");
return ( return (
<footer> <footer>
<p>&copy; 2025 Your Company</p> <p>&copy; 2025 Your Company</p>

View File

@@ -1,6 +1,7 @@
import Navigation from "./Navigation"; import Navigation from "./Navigation";
const Header = () => { const Header = () => {
console.log("Header rendered");
return ( return (
<header> <header>
<h2>My Application</h2> <h2>My Application</h2>

View File

@@ -1,4 +1,5 @@
export default function Heading({title = "Hallo Teilnehmer"}: {title?: string}): React.ReactElement { export default function Heading({title = "Hallo Teilnehmer"}: {title?: string}): React.ReactElement {
console.log("Heading rendered");
return ( return (
<h1 > <h1 >
{title} {title}

View File

@@ -1,11 +1,25 @@
import { useState } from "react";
import Footer from "../components/Footer"; import Footer from "../components/Footer";
import Header from "../components/Header"; import Header from "../components/Header";
export default function MainLayout({children}: {children: React.ReactNode | React.ReactElement | React.ReactElement[]}): React.ReactElement { export default function MainLayout({children}: {children: React.ReactNode | React.ReactElement | React.ReactElement[]}): React.ReactElement {
const [clicked, setClicked] = useState(false);
function handleClick() {
setClicked(!clicked);
console.log("clicked", clicked);
}
console.log("MainLayout rendered", clicked);
return ( return (
<> <>
<Header /> <Header />
{children} {children}
<button onClick={handleClick}>Click</button>
<Footer /> <Footer />
</> </>
); );