File tree Expand file tree Collapse file tree 13 files changed +280
-2
lines changed
code/03 React Essentials/01-starting-project/src/components Expand file tree Collapse file tree 13 files changed +280
-2
lines changed Original file line number Diff line number Diff line change 1- export default function TabButton ( props ) {
1+ export default function TabButton ( { children } ) {
2+ function handleClick ( ) {
3+ console . log ( "Hello World!" ) ;
4+ }
25 return (
36 < li >
4- < button > { props . children } </ button >
7+ < button onClick = { handleClick } > { children } </ button >
58 </ li >
69 ) ;
710}
Original file line number Diff line number Diff line change 1+ # Logs
2+ logs
3+ * .log
4+ npm-debug.log *
5+ yarn-debug.log *
6+ yarn-error.log *
7+ pnpm-debug.log *
8+ lerna-debug.log *
9+
10+ node_modules
11+ dist
12+ dist-ssr
13+ * .local
14+
15+ # Editor directories and files
16+ .vscode /*
17+ ! .vscode /extensions.json
18+ .idea
19+ .DS_Store
20+ * .suo
21+ * .ntvs *
22+ * .njsproj
23+ * .sln
24+ * .sw ?
Original file line number Diff line number Diff line change 1+ # React + Vite
2+
3+ This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
4+
5+ Currently, two official plugins are available:
6+
7+ - [ @vitejs/plugin-react ] ( https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md ) uses [ Babel] ( https://babeljs.io/ ) for Fast Refresh
8+ - [ @vitejs/plugin-react-swc ] ( https://github.com/vitejs/vite-plugin-react-swc ) uses [ SWC] ( https://swc.rs/ ) for Fast Refresh
Original file line number Diff line number Diff line change 1+ import js from '@eslint/js'
2+ import globals from 'globals'
3+ import react from 'eslint-plugin-react'
4+ import reactHooks from 'eslint-plugin-react-hooks'
5+ import reactRefresh from 'eslint-plugin-react-refresh'
6+
7+ export default [
8+ { ignores : [ 'dist' ] } ,
9+ {
10+ files : [ '**/*.{js,jsx}' ] ,
11+ languageOptions : {
12+ ecmaVersion : 2020 ,
13+ globals : globals . browser ,
14+ parserOptions : {
15+ ecmaVersion : 'latest' ,
16+ ecmaFeatures : { jsx : true } ,
17+ sourceType : 'module' ,
18+ } ,
19+ } ,
20+ settings : { react : { version : '18.3' } } ,
21+ plugins : {
22+ react,
23+ 'react-hooks' : reactHooks ,
24+ 'react-refresh' : reactRefresh ,
25+ } ,
26+ rules : {
27+ ...js . configs . recommended . rules ,
28+ ...react . configs . recommended . rules ,
29+ ...react . configs [ 'jsx-runtime' ] . rules ,
30+ ...reactHooks . configs . recommended . rules ,
31+ 'react/jsx-no-target-blank' : 'off' ,
32+ 'react-refresh/only-export-components' : [
33+ 'warn' ,
34+ { allowConstantExport : true } ,
35+ ] ,
36+ } ,
37+ } ,
38+ ]
Original file line number Diff line number Diff line change 1+ <!doctype html>
2+ < html lang ="en ">
3+ < head >
4+ < meta charset ="UTF-8 " />
5+ < link rel ="icon " type ="image/svg+xml " href ="/vite.svg " />
6+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 " />
7+ < title > Vite + React</ title >
8+ </ head >
9+ < body >
10+ < div id ="root "> </ div >
11+ < script type ="module " src ="/src/main.jsx "> </ script >
12+ </ body >
13+ </ html >
Original file line number Diff line number Diff line change 1+ {
2+ "name" : " vite-project" ,
3+ "private" : true ,
4+ "version" : " 0.0.0" ,
5+ "type" : " module" ,
6+ "scripts" : {
7+ "dev" : " vite" ,
8+ "build" : " vite build" ,
9+ "lint" : " eslint ." ,
10+ "preview" : " vite preview"
11+ },
12+ "dependencies" : {
13+ "react" : " ^18.3.1" ,
14+ "react-dom" : " ^18.3.1"
15+ },
16+ "devDependencies" : {
17+ "@eslint/js" : " ^9.9.0" ,
18+ "@types/react" : " ^18.3.3" ,
19+ "@types/react-dom" : " ^18.3.0" ,
20+ "@vitejs/plugin-react" : " ^4.3.1" ,
21+ "eslint" : " ^9.9.0" ,
22+ "eslint-plugin-react" : " ^7.35.0" ,
23+ "eslint-plugin-react-hooks" : " ^5.1.0-rc.0" ,
24+ "eslint-plugin-react-refresh" : " ^0.4.9" ,
25+ "globals" : " ^15.9.0" ,
26+ "vite" : " ^5.4.1"
27+ }
28+ }
Original file line number Diff line number Diff line change 1+ # root {
2+ max-width : 1280px ;
3+ margin : 0 auto;
4+ padding : 2rem ;
5+ text-align : center;
6+ }
7+
8+ .logo {
9+ height : 6em ;
10+ padding : 1.5em ;
11+ will-change : filter;
12+ transition : filter 300ms ;
13+ }
14+ .logo : hover {
15+ filter : drop-shadow (0 0 2em # 646cffaa );
16+ }
17+ .logo .react : hover {
18+ filter : drop-shadow (0 0 2em # 61dafbaa );
19+ }
20+
21+ @keyframes logo-spin {
22+ from {
23+ transform : rotate (0deg );
24+ }
25+ to {
26+ transform : rotate (360deg );
27+ }
28+ }
29+
30+ @media (prefers-reduced-motion : no-preference) {
31+ a : nth-of-type (2 ) .logo {
32+ animation : logo-spin infinite 20s linear;
33+ }
34+ }
35+
36+ .card {
37+ padding : 2em ;
38+ }
39+
40+ .read-the-docs {
41+ color : # 888 ;
42+ }
Original file line number Diff line number Diff line change 1+ import { useState } from 'react'
2+ import reactLogo from './assets/react.svg'
3+ import viteLogo from '/vite.svg'
4+ import './App.css'
5+
6+ function App ( ) {
7+ const [ count , setCount ] = useState ( 0 )
8+
9+ return (
10+ < >
11+ < div >
12+ < a href = "https://vitejs.dev" target = "_blank" >
13+ < img src = { viteLogo } className = "logo" alt = "Vite logo" />
14+ </ a >
15+ < a href = "https://react.dev" target = "_blank" >
16+ < img src = { reactLogo } className = "logo react" alt = "React logo" />
17+ </ a >
18+ </ div >
19+ < h1 > Vite + React</ h1 >
20+ < div className = "card" >
21+ < button onClick = { ( ) => setCount ( ( count ) => count + 1 ) } >
22+ count is { count }
23+ </ button >
24+ < p >
25+ Edit < code > src/App.jsx</ code > and save to test HMR
26+ </ p >
27+ </ div >
28+ < p className = "read-the-docs" >
29+ Click on the Vite and React logos to learn more
30+ </ p >
31+ </ >
32+ )
33+ }
34+
35+ export default App
You can’t perform that action at this time.
0 commit comments