rerender issue
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
function Footer() {
|
function Footer() {
|
||||||
|
console.log("Footer rendered");
|
||||||
return (
|
return (
|
||||||
<footer>
|
<footer>
|
||||||
<p>© 2025 Your Company</p>
|
<p>© 2025 Your Company</p>
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
@@ -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}
|
||||||
|
|||||||
@@ -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 />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user