Skip to content

Commit 1da9998

Browse files
author
Matej Snuderl
committed
add some ssr to page
1 parent 72c7a01 commit 1da9998

File tree

6 files changed

+273
-212
lines changed

6 files changed

+273
-212
lines changed

package.json

+9-7
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@
2828
"storybook": "start-storybook"
2929
},
3030
"dependencies": {
31-
"next": "^9.3.2",
31+
"ky": "^0.19.0",
32+
"ky-universal": "^0.5.0",
33+
"next": "^9.3.3",
3234
"react": "^16.12.0",
3335
"react-dom": "^16.12.0"
3436
},
@@ -41,10 +43,10 @@
4143
"@testing-library/react": "^10.0.1",
4244
"@testing-library/testcafe": "^4.0.0",
4345
"@types/jest": "^25.1.4",
44-
"@types/node": "^13.1.8",
46+
"@types/node": "^13.9.8",
4547
"@types/react": "^16.9.19",
46-
"@typescript-eslint/eslint-plugin": "^2.17.0",
47-
"@typescript-eslint/parser": "^2.17.0",
48+
"@typescript-eslint/eslint-plugin": "^2.26.0",
49+
"@typescript-eslint/parser": "^2.26.0",
4850
"awesome-typescript-loader": "^5.2.1",
4951
"babel-loader": "^8.1.0",
5052
"concurrently": "^5.0.2",
@@ -53,12 +55,12 @@
5355
"eslint-plugin-prettier": "^3.1.2",
5456
"eslint-plugin-react": "^7.18.0",
5557
"eslint-plugin-testcafe": "^0.2.1",
56-
"jest": "^25.1.0",
58+
"jest": "^25.2.4",
5759
"prettier": "^2.0.2",
5860
"serverless": "^1.61.3",
59-
"serverless-next.js": "^1.8.0",
61+
"serverless-next.js": "^1.9.7",
6062
"testcafe": "^1.8.1",
61-
"ts-jest": "^25.0.0",
63+
"ts-jest": "^25.3.0",
6264
"typescript": "^3.7.5",
6365
"wait-on": "^4.0.0"
6466
},

src/containers/AboutPage/AboutPage.stories.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ export default {
66
title: 'AboutPage',
77
};
88

9-
export const Default = () => <AboutPage />;
9+
export const Default = () => <AboutPage todos={{}} />;

src/containers/AboutPage/AboutPage.tsx

+8-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ import Link from 'next/link';
33

44
import AboutUs from 'components/AboutUs';
55

6-
const About: React.FC = () => {
6+
type Props = {
7+
todos: object;
8+
};
9+
10+
const About = ({ todos }: Props) => {
711
return (
812
<>
913
<ul>
@@ -16,6 +20,9 @@ const About: React.FC = () => {
1620
</ul>
1721

1822
<AboutUs />
23+
24+
<div>TODOS:</div>
25+
<div>{JSON.stringify(todos)}</div>
1926
</>
2027
);
2128
};

src/containers/HomePage/HomePage.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import Link from 'next/link';
33

4-
const HomePage: React.FC = () => {
4+
const HomePage = () => {
55
return (
66
<>
77
<ul>

src/pages/about.tsx

+13-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
11
import React from 'react';
2+
import ky from 'ky-universal';
3+
import { GetServerSideProps } from 'next';
24

35
import AboutPage from '../containers/AboutPage';
46

5-
const About = () => {
6-
return <AboutPage />;
7+
type Props = {
8+
todos: object;
9+
};
10+
11+
const About = ({ todos }: Props) => {
12+
return <AboutPage todos={todos} />;
13+
};
14+
15+
export const getServerSideProps: GetServerSideProps<Props> = async (_ctx) => {
16+
const todos = await ky('https://jsonplaceholder.typicode.com/todos/1').json<object>();
17+
return { props: { todos } };
718
};
819

920
export default About;

0 commit comments

Comments
 (0)