Skip to content

Commit aa5be3f

Browse files
authoredSep 7, 2022
[Docs] Migrate with-react-jss to typescript (vercel#40308)
## Documentation / Examples - [x] Make sure the linting passes by running `pnpm lint` - [x] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
1 parent 62c7eff commit aa5be3f

File tree

6 files changed

+34
-13
lines changed

6 files changed

+34
-13
lines changed
 

‎examples/with-react-jss/.babelrc

-3
This file was deleted.

‎examples/with-react-jss/package.json

+8-3
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,13 @@
77
},
88
"dependencies": {
99
"next": "latest",
10-
"react": "^17.0.2",
11-
"react-dom": "^17.0.2",
12-
"react-jss": "^10.3.0"
10+
"react": "^18.2.0",
11+
"react-dom": "^18.2.0",
12+
"react-jss": "^10.9.2"
13+
},
14+
"devDependencies": {
15+
"@types/node": "18.7.15",
16+
"@types/react": "18.0.18",
17+
"typescript": "4.8.2"
1318
}
1419
}

‎examples/with-react-jss/pages/_app.js ‎examples/with-react-jss/pages/_app.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
import type { AppProps } from 'next/app'
12
import { useEffect } from 'react'
23

3-
export default function App({ Component, pageProps }) {
4+
export default function App({ Component, pageProps }: AppProps) {
45
useEffect(() => {
56
const style = document.getElementById('server-side-styles')
6-
if (style) {
7+
if (style && style.parentNode) {
78
style.parentNode.removeChild(style)
89
}
910
}, [])

‎examples/with-react-jss/pages/_document.js ‎examples/with-react-jss/pages/_document.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import Document from 'next/document'
1+
import Document, { DocumentContext } from 'next/document'
22
import { SheetsRegistry, JssProvider, createGenerateId } from 'react-jss'
33

44
export default class JssDocument extends Document {
5-
static async getInitialProps(ctx) {
5+
static async getInitialProps(ctx: DocumentContext) {
66
const registry = new SheetsRegistry()
77
const generateId = createGenerateId()
88
const originalRenderPage = ctx.renderPage

‎examples/with-react-jss/pages/index.js ‎examples/with-react-jss/pages/index.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const useStyles = createUseStyles({
1212
},
1313
})
1414

15-
function Index() {
15+
export default function IndexPage() {
1616
const classes = useStyles()
1717

1818
return (
@@ -23,5 +23,3 @@ function Index() {
2323
</div>
2424
)
2525
}
26-
27-
export default Index

‎examples/with-react-jss/tsconfig.json

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es5",
4+
"lib": ["dom", "dom.iterable", "esnext"],
5+
"allowJs": true,
6+
"skipLibCheck": true,
7+
"strict": true,
8+
"forceConsistentCasingInFileNames": true,
9+
"noEmit": true,
10+
"incremental": true,
11+
"esModuleInterop": true,
12+
"moduleResolution": "node",
13+
"module": "esnext",
14+
"resolveJsonModule": true,
15+
"isolatedModules": true,
16+
"jsx": "preserve"
17+
},
18+
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
19+
"exclude": ["node_modules"]
20+
}

0 commit comments

Comments
 (0)
Please sign in to comment.