Skip to content

Commit 386b5b9

Browse files
update template with react 18
1 parent 568f941 commit 386b5b9

File tree

13 files changed

+223
-65
lines changed

13 files changed

+223
-65
lines changed

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
1-
/node_modules
1+
/node_modules
2+
3+
template/package.json
4+
template/package-lock.json
5+
template/node_modules
6+
template/.husky

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
}
3737
},
3838
"lint-staged": {
39-
"./**/*.{js,ts,tsx,css,md,json}": [
39+
"./**/*.{js,ts,tsx}": [
4040
"prettier --write",
4141
"eslint --fix"
4242
]

template.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,28 @@
33
"scripts": {
44
"postinstall": "husky install && npx husky add .husky/pre-commit \"npx lint-staged\"",
55
"husky:prepare": "husky install && npx husky add .husky/pre-commit \"npx lint-staged\"",
6+
"start": "react-scripts start",
7+
"build": "react-scripts build",
8+
"eject": "react-scripts eject",
69
"lint": "eslint .",
710
"lint:fix": "eslint --fix",
811
"format": "prettier --write \"./**/*.{js,ts,tsx,css,json}\" --config ./.prettierrc"
912
},
13+
"dependencies": {
14+
"@types/node": "^16.11.37",
15+
"@types/react": "^18.0.10",
16+
"@types/react-dom": "^18.0.5",
17+
"autoprefixer": "^10.4.7",
18+
"postcss": "^8.4.14",
19+
"postcss-cli": "^9.1.0",
20+
"postcss-preset-env": "^7.7.0",
21+
"react": "^18.1.0",
22+
"react-dom": "^18.1.0",
23+
"react-scripts": "5.0.1",
24+
"tailwindcss": "^3.0.24",
25+
"typescript": "^4.7.2",
26+
"web-vitals": "^2.1.4"
27+
},
1028
"devDependencies": {
1129
"@typescript-eslint/eslint-plugin": "^5.27.0",
1230
"@typescript-eslint/parser": "^5.27.0",
@@ -21,6 +39,23 @@
2139
"husky": "^8.0.1",
2240
"prettier": "^2.6.2"
2341
},
42+
"eslintConfig": {
43+
"extends": [
44+
"react-app"
45+
]
46+
},
47+
"browserslist": {
48+
"production": [
49+
">0.2%",
50+
"not dead",
51+
"not op_mini all"
52+
],
53+
"development": [
54+
"last 1 chrome version",
55+
"last 1 firefox version",
56+
"last 1 safari version"
57+
]
58+
},
2459
"husky": {
2560
"hooks": {
2661
"pre-commit": "lint-staged"
File renamed without changes.

template/README.md

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ In the project directory, you can run:
99
### `npm start`
1010

1111
Runs the app in the development mode.\
12-
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
12+
Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
1313

14-
The page will reload if you make edits.\
15-
You will also see any lint errors in the console.
14+
The page will reload when you make changes.\
15+
You may also see any lint errors in the console.
1616

1717
### `npm test`
1818

@@ -31,16 +31,40 @@ See the section about [deployment](https://facebook.github.io/create-react-app/d
3131

3232
### `npm run eject`
3333

34-
**Note: this is a one-way operation. Once you `eject`, you cant go back!**
34+
**Note: this is a one-way operation. Once you `eject`, you can't go back!**
3535

36-
If you arent satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
36+
If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
3737

38-
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point youre on your own.
38+
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.
3939

40-
You dont have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldnt feel obligated to use this feature. However we understand that this tool wouldnt be useful if you couldnt customize it when you are ready for it.
40+
You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.
4141

4242
## Learn More
4343

4444
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
4545

4646
To learn React, check out the [React documentation](https://reactjs.org/).
47+
48+
### Code Splitting
49+
50+
This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
51+
52+
### Analyzing the Bundle Size
53+
54+
This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
55+
56+
### Making a Progressive Web App
57+
58+
This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
59+
60+
### Advanced Configuration
61+
62+
This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
63+
64+
### Deployment
65+
66+
This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
67+
68+
### `npm run build` fails to minify
69+
70+
This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)

template/postcss.config.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

template/src/App.tsx

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
1-
import React from "react";
2-
import logo from "./logo.svg";
3-
41
function App() {
52
return (
6-
<div className="App">
7-
<header className="App-header">
8-
<img src={logo} className="App-logo" alt="logo" />
9-
<p>
10-
Edit <code>src/App.tsx</code> and save to reload.
3+
<div className="w-screen min-h-screen flex flex-col items-center justify-center bg-gray-800">
4+
<header className="border border-gray-600 rounded-lg p-10">
5+
<h1 className="text-center text-2xl font-bold text-gray-300 mb-5">
6+
CRA-TEMPLATE-REACT-TS-TW
7+
</h1>
8+
<p className="text-gray-400">
9+
Edit{" "}
10+
<code className="bg-blue-900 p-1 mx-2 rounded-md">'src/App.tsx'</code>{" "}
11+
and save to reload.
1112
</p>
12-
<a
13-
className="App-link"
14-
href="https://reactjs.org"
15-
target="_blank"
16-
rel="noopener noreferrer"
17-
>
18-
Learn React
13+
<a href="https://reactjs.org" target="_blank" rel="noopener noreferrer">
14+
<div className="bg-gray-600 hover:bg-gray-700 py-2 px-3 text-center mt-5 rounded-md text-gray-300 font-bold">
15+
Learn React
16+
</div>
1917
</a>
2018
</header>
2119
</div>

template/src/index.css

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
/* @tailwind base; */
1+
@tailwind base;
2+
@tailwind components;
3+
@tailwind utilities;
24

3-
/* Your own custom base styles */
5+
body {
6+
margin: 0;
7+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
8+
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
9+
sans-serif;
10+
-webkit-font-smoothing: antialiased;
11+
-moz-osx-font-smoothing: grayscale;
12+
}
413

5-
/* Start purging... */
6-
/* @tailwind components; */
7-
/* Stop purging. */
8-
9-
/* Your own custom component styles */
10-
11-
/* Start purging... */
12-
/* @tailwind utilities; */
13-
/* Stop purging. */
14-
15-
/* Your own custom utilities */
14+
code {
15+
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
16+
monospace;
17+
}

template/src/index.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
import React from "react";
2-
import ReactDOM from "react-dom/client";
2+
import { createRoot } from "react-dom/client";
33
import "./index.css";
44
import App from "./App";
5+
import reportWebVitals from "./reportWebVitals";
56

6-
const root = ReactDOM.createRoot(
7-
document.getElementById("root") as HTMLElement,
8-
);
7+
const container = document.getElementById("root");
8+
const root = createRoot(container!); // createRoot(container!) if you use TypeScript
99
root.render(
1010
<React.StrictMode>
1111
<App />
1212
</React.StrictMode>,
1313
);
14+
15+
// If you want to start measuring performance in your app, pass a function
16+
// to log results (for example: reportWebVitals(console.log))
17+
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
18+
reportWebVitals();

template/src/logo.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)