Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated nested-components example to use App Router #68065

Merged
merged 8 commits into from
Jul 25, 2024
2 changes: 1 addition & 1 deletion examples/nested-components/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Example app using nested components

Taking advantage of the composable nature of React components we can modularize our apps in self-contained, meaningful components. This example has a page under `pages/index.tsx` that uses `components/paragraph.tsx` and `components/post.tsx` that can be styled and managed separately.
Taking advantage of the composable nature of React components we can modularize our apps in self-contained, meaningful components. This example has a page under `app/page.tsx` that uses `app/_components/paragraph.tsx` and `app/_components/post.tsx` that can be styled and managed separately.

## Deploy your own

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default function Paragraph({ children }: ParagraphProps) {
return (
<p>
{children}
<style jsx>{`
<style>{`
p {
font:
13px Helvetica,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default function Post({ title, children }: PostProps) {
<div className="main">
<h1>{title}</h1>
{children}
<style jsx>{`
<style>{`
.main {
font:
15px Helvetica,
Expand Down
16 changes: 16 additions & 0 deletions examples/nested-components/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export const metadata = {
title: "Next.js",
description: "Generated by Next.js",
};

export default function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
return (
<html lang="en">
<body>{children}</body>
</html>
);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import P from "../components/paragraph";
import Post from "../components/post";
import P from "./_components/paragraph";
import Post from "./_components/post";

export default function Home() {
return (
Expand All @@ -23,7 +23,7 @@ export default function Home() {
<P>C’est fin</P>
</Post>

<style jsx>{`
<style>{`
.main {
margin: auto;
max-width: 420px;
Expand Down
12 changes: 6 additions & 6 deletions examples/nested-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
},
"dependencies": {
"next": "latest",
"react": "^18.2.0",
"react-dom": "^18.2.0"
"react": "^18.3.1",
"react-dom": "^18.3.1"
},
"devDependencies": {
"@types/node": "^18.11.5",
"@types/react": "^18.0.23",
"@types/react-dom": "^18.0.7",
"typescript": "^4.8.4"
"@types/node": "^20.14.12",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"typescript": "^5.5.4"
}
}
Loading