fpythons 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- fpythons-0.1.0/.gitignore +5 -0
- fpythons-0.1.0/PKG-INFO +64 -0
- fpythons-0.1.0/README.md +57 -0
- fpythons-0.1.0/fpythons/__init__.py +12 -0
- fpythons-0.1.0/fpythons/__main__.py +4 -0
- fpythons-0.1.0/fpythons/data/00_START_HERE.md +144 -0
- fpythons-0.1.0/fpythons/data/ALL_SLIPS_CODE.txt +1854 -0
- fpythons-0.1.0/fpythons/data/README.md +35 -0
- fpythons-0.1.0/fpythons/data/Slip_01.md +160 -0
- fpythons-0.1.0/fpythons/data/Slip_02.md +104 -0
- fpythons-0.1.0/fpythons/data/Slip_03.md +95 -0
- fpythons-0.1.0/fpythons/data/Slip_04.md +131 -0
- fpythons-0.1.0/fpythons/data/Slip_05.md +120 -0
- fpythons-0.1.0/fpythons/data/Slip_06.md +161 -0
- fpythons-0.1.0/fpythons/data/Slip_07.md +121 -0
- fpythons-0.1.0/fpythons/data/Slip_08.md +95 -0
- fpythons-0.1.0/fpythons/data/Slip_09.md +92 -0
- fpythons-0.1.0/fpythons/data/Slip_10.md +113 -0
- fpythons-0.1.0/fpythons/data/Slip_11.md +109 -0
- fpythons-0.1.0/fpythons/data/Slip_12.md +181 -0
- fpythons-0.1.0/fpythons/data/Slip_13.md +163 -0
- fpythons-0.1.0/fpythons/data/Slip_14.md +141 -0
- fpythons-0.1.0/fpythons/data/Slip_15.md +100 -0
- fpythons-0.1.0/fpythons/data/Slip_16.md +127 -0
- fpythons-0.1.0/fpythons/data/Slip_17.md +93 -0
- fpythons-0.1.0/fpythons/data/Slip_18.md +96 -0
- fpythons-0.1.0/fpythons/data/Slip_19.md +94 -0
- fpythons-0.1.0/fpythons/data/Slip_20.md +165 -0
- fpythons-0.1.0/fpythons/data/Slip_21.md +122 -0
- fpythons-0.1.0/fpythons/data/VIVA.md +195 -0
- fpythons-0.1.0/fpythons/data/code/slip1/.gitignore +2 -0
- fpythons-0.1.0/fpythons/data/code/slip1/package.json +31 -0
- fpythons-0.1.0/fpythons/data/code/slip1/public/index.html +12 -0
- fpythons-0.1.0/fpythons/data/code/slip1/src/App.js +7 -0
- fpythons-0.1.0/fpythons/data/code/slip1/src/index.js +10 -0
- fpythons-0.1.0/fpythons/data/code/slip1/src/slip1/loginForm.js +26 -0
- fpythons-0.1.0/fpythons/data/code/slip1/src/slip1/style.css +46 -0
- fpythons-0.1.0/fpythons/data/code/slip10/.gitignore +2 -0
- fpythons-0.1.0/fpythons/data/code/slip10/package.json +31 -0
- fpythons-0.1.0/fpythons/data/code/slip10/public/index.html +12 -0
- fpythons-0.1.0/fpythons/data/code/slip10/src/App.js +7 -0
- fpythons-0.1.0/fpythons/data/code/slip10/src/index.js +10 -0
- fpythons-0.1.0/fpythons/data/code/slip10/src/slip10/SumOfDigits.js +37 -0
- fpythons-0.1.0/fpythons/data/code/slip11/.gitignore +2 -0
- fpythons-0.1.0/fpythons/data/code/slip11/package.json +31 -0
- fpythons-0.1.0/fpythons/data/code/slip11/public/index.html +12 -0
- fpythons-0.1.0/fpythons/data/code/slip11/src/App.js +7 -0
- fpythons-0.1.0/fpythons/data/code/slip11/src/index.js +10 -0
- fpythons-0.1.0/fpythons/data/code/slip11/src/slip11/StringOperation.js +33 -0
- fpythons-0.1.0/fpythons/data/code/slip12/.gitignore +2 -0
- fpythons-0.1.0/fpythons/data/code/slip12/package.json +33 -0
- fpythons-0.1.0/fpythons/data/code/slip12/public/index.html +12 -0
- fpythons-0.1.0/fpythons/data/code/slip12/src/App.js +7 -0
- fpythons-0.1.0/fpythons/data/code/slip12/src/index.js +14 -0
- fpythons-0.1.0/fpythons/data/code/slip12/src/slip12/NotesManagementApp.js +35 -0
- fpythons-0.1.0/fpythons/data/code/slip12/src/slip12/redux/notesSlice.js +20 -0
- fpythons-0.1.0/fpythons/data/code/slip12/src/slip12/redux/store.js +10 -0
- fpythons-0.1.0/fpythons/data/code/slip13/.gitignore +2 -0
- fpythons-0.1.0/fpythons/data/code/slip13/package.json +33 -0
- fpythons-0.1.0/fpythons/data/code/slip13/public/index.html +12 -0
- fpythons-0.1.0/fpythons/data/code/slip13/src/App.js +7 -0
- fpythons-0.1.0/fpythons/data/code/slip13/src/index.js +14 -0
- fpythons-0.1.0/fpythons/data/code/slip13/src/slip13/Counter.js +20 -0
- fpythons-0.1.0/fpythons/data/code/slip13/src/slip13/redux/counterSlice.js +19 -0
- fpythons-0.1.0/fpythons/data/code/slip13/src/slip13/redux/store.js +10 -0
- fpythons-0.1.0/fpythons/data/code/slip14/.gitignore +2 -0
- fpythons-0.1.0/fpythons/data/code/slip14/package.json +31 -0
- fpythons-0.1.0/fpythons/data/code/slip14/public/index.html +12 -0
- fpythons-0.1.0/fpythons/data/code/slip14/src/App.js +7 -0
- fpythons-0.1.0/fpythons/data/code/slip14/src/index.js +10 -0
- fpythons-0.1.0/fpythons/data/code/slip14/src/slip14/Calculator.js +64 -0
- fpythons-0.1.0/fpythons/data/code/slip15/.gitignore +2 -0
- fpythons-0.1.0/fpythons/data/code/slip15/package.json +31 -0
- fpythons-0.1.0/fpythons/data/code/slip15/public/index.html +12 -0
- fpythons-0.1.0/fpythons/data/code/slip15/src/App.js +7 -0
- fpythons-0.1.0/fpythons/data/code/slip15/src/index.js +10 -0
- fpythons-0.1.0/fpythons/data/code/slip15/src/slip15/Counter.js +24 -0
- fpythons-0.1.0/fpythons/data/code/slip16/.gitignore +2 -0
- fpythons-0.1.0/fpythons/data/code/slip16/package.json +31 -0
- fpythons-0.1.0/fpythons/data/code/slip16/public/index.html +12 -0
- fpythons-0.1.0/fpythons/data/code/slip16/src/App.js +7 -0
- fpythons-0.1.0/fpythons/data/code/slip16/src/index.js +10 -0
- fpythons-0.1.0/fpythons/data/code/slip16/src/slip16/TraditionalDOM.html +24 -0
- fpythons-0.1.0/fpythons/data/code/slip16/src/slip16/VirtualDOM.js +16 -0
- fpythons-0.1.0/fpythons/data/code/slip17/.gitignore +2 -0
- fpythons-0.1.0/fpythons/data/code/slip17/package.json +31 -0
- fpythons-0.1.0/fpythons/data/code/slip17/public/index.html +12 -0
- fpythons-0.1.0/fpythons/data/code/slip17/src/App.js +7 -0
- fpythons-0.1.0/fpythons/data/code/slip17/src/index.js +10 -0
- fpythons-0.1.0/fpythons/data/code/slip17/src/slip17/Sign-in.js +17 -0
- fpythons-0.1.0/fpythons/data/code/slip18/.gitignore +2 -0
- fpythons-0.1.0/fpythons/data/code/slip18/package.json +31 -0
- fpythons-0.1.0/fpythons/data/code/slip18/public/index.html +12 -0
- fpythons-0.1.0/fpythons/data/code/slip18/public/logo192.png +0 -0
- fpythons-0.1.0/fpythons/data/code/slip18/src/App.js +7 -0
- fpythons-0.1.0/fpythons/data/code/slip18/src/index.js +10 -0
- fpythons-0.1.0/fpythons/data/code/slip18/src/slip18/Profile.js +20 -0
- fpythons-0.1.0/fpythons/data/code/slip19/.gitignore +2 -0
- fpythons-0.1.0/fpythons/data/code/slip19/package.json +31 -0
- fpythons-0.1.0/fpythons/data/code/slip19/public/index.html +12 -0
- fpythons-0.1.0/fpythons/data/code/slip19/src/App.js +7 -0
- fpythons-0.1.0/fpythons/data/code/slip19/src/index.js +10 -0
- fpythons-0.1.0/fpythons/data/code/slip19/src/slip19/Movies.js +19 -0
- fpythons-0.1.0/fpythons/data/code/slip2/.gitignore +2 -0
- fpythons-0.1.0/fpythons/data/code/slip2/package.json +31 -0
- fpythons-0.1.0/fpythons/data/code/slip2/public/index.html +12 -0
- fpythons-0.1.0/fpythons/data/code/slip2/src/App.js +7 -0
- fpythons-0.1.0/fpythons/data/code/slip2/src/index.js +10 -0
- fpythons-0.1.0/fpythons/data/code/slip2/src/slip2/useEffect.js +23 -0
- fpythons-0.1.0/fpythons/data/code/slip20/.gitignore +2 -0
- fpythons-0.1.0/fpythons/data/code/slip20/package.json +32 -0
- fpythons-0.1.0/fpythons/data/code/slip20/public/index.html +12 -0
- fpythons-0.1.0/fpythons/data/code/slip20/src/App.js +16 -0
- fpythons-0.1.0/fpythons/data/code/slip20/src/index.js +10 -0
- fpythons-0.1.0/fpythons/data/code/slip20/src/slip20/Login.js +45 -0
- fpythons-0.1.0/fpythons/data/code/slip20/src/slip20/Students.js +27 -0
- fpythons-0.1.0/fpythons/data/code/slip21/.gitignore +2 -0
- fpythons-0.1.0/fpythons/data/code/slip21/package.json +31 -0
- fpythons-0.1.0/fpythons/data/code/slip21/public/index.html +12 -0
- fpythons-0.1.0/fpythons/data/code/slip21/src/App.js +7 -0
- fpythons-0.1.0/fpythons/data/code/slip21/src/index.js +10 -0
- fpythons-0.1.0/fpythons/data/code/slip21/src/slip21/NumberString.js +46 -0
- fpythons-0.1.0/fpythons/data/code/slip3/.gitignore +2 -0
- fpythons-0.1.0/fpythons/data/code/slip3/package.json +31 -0
- fpythons-0.1.0/fpythons/data/code/slip3/public/index.html +12 -0
- fpythons-0.1.0/fpythons/data/code/slip3/src/App.js +7 -0
- fpythons-0.1.0/fpythons/data/code/slip3/src/index.js +10 -0
- fpythons-0.1.0/fpythons/data/code/slip3/src/slip3/toggleBtn.js +16 -0
- fpythons-0.1.0/fpythons/data/code/slip4/.gitignore +2 -0
- fpythons-0.1.0/fpythons/data/code/slip4/package.json +32 -0
- fpythons-0.1.0/fpythons/data/code/slip4/public/index.html +12 -0
- fpythons-0.1.0/fpythons/data/code/slip4/src/App.js +23 -0
- fpythons-0.1.0/fpythons/data/code/slip4/src/index.js +10 -0
- fpythons-0.1.0/fpythons/data/code/slip4/src/slip4/About.js +7 -0
- fpythons-0.1.0/fpythons/data/code/slip4/src/slip4/Contact.js +7 -0
- fpythons-0.1.0/fpythons/data/code/slip4/src/slip4/home.js +7 -0
- fpythons-0.1.0/fpythons/data/code/slip5/.gitignore +2 -0
- fpythons-0.1.0/fpythons/data/code/slip5/package.json +32 -0
- fpythons-0.1.0/fpythons/data/code/slip5/public/index.html +12 -0
- fpythons-0.1.0/fpythons/data/code/slip5/src/App.js +18 -0
- fpythons-0.1.0/fpythons/data/code/slip5/src/index.js +10 -0
- fpythons-0.1.0/fpythons/data/code/slip5/src/slip5/loginValidation.js +30 -0
- fpythons-0.1.0/fpythons/data/code/slip6/.gitignore +2 -0
- fpythons-0.1.0/fpythons/data/code/slip6/package.json +32 -0
- fpythons-0.1.0/fpythons/data/code/slip6/public/index.html +12 -0
- fpythons-0.1.0/fpythons/data/code/slip6/src/App.js +31 -0
- fpythons-0.1.0/fpythons/data/code/slip6/src/index.js +10 -0
- fpythons-0.1.0/fpythons/data/code/slip6/src/slip6/Dashboard.js +12 -0
- fpythons-0.1.0/fpythons/data/code/slip6/src/slip6/Login.js +23 -0
- fpythons-0.1.0/fpythons/data/code/slip6/src/slip6/ProtectedRoute.js +10 -0
- fpythons-0.1.0/fpythons/data/code/slip7/.gitignore +2 -0
- fpythons-0.1.0/fpythons/data/code/slip7/package.json +31 -0
- fpythons-0.1.0/fpythons/data/code/slip7/public/index.html +12 -0
- fpythons-0.1.0/fpythons/data/code/slip7/src/App.js +7 -0
- fpythons-0.1.0/fpythons/data/code/slip7/src/index.js +10 -0
- fpythons-0.1.0/fpythons/data/code/slip7/src/slip7/TodoList.js +42 -0
- fpythons-0.1.0/fpythons/data/code/slip8/.gitignore +2 -0
- fpythons-0.1.0/fpythons/data/code/slip8/package.json +31 -0
- fpythons-0.1.0/fpythons/data/code/slip8/public/index.html +12 -0
- fpythons-0.1.0/fpythons/data/code/slip8/src/App.js +7 -0
- fpythons-0.1.0/fpythons/data/code/slip8/src/index.js +10 -0
- fpythons-0.1.0/fpythons/data/code/slip8/src/slip8/ToggleButton.js +19 -0
- fpythons-0.1.0/fpythons/data/code/slip9/.gitignore +2 -0
- fpythons-0.1.0/fpythons/data/code/slip9/package.json +31 -0
- fpythons-0.1.0/fpythons/data/code/slip9/public/index.html +12 -0
- fpythons-0.1.0/fpythons/data/code/slip9/src/App.js +7 -0
- fpythons-0.1.0/fpythons/data/code/slip9/src/index.js +10 -0
- fpythons-0.1.0/fpythons/data/code/slip9/src/slip9/Counter.js +16 -0
- fpythons-0.1.0/fpythons/main.py +226 -0
- fpythons-0.1.0/pyproject.toml +21 -0
- fpythons-0.1.0/slips/00_START_HERE.md +144 -0
- fpythons-0.1.0/slips/notes.md +588 -0
- fpythons-0.1.0/slips/slip1/App.js +7 -0
- fpythons-0.1.0/slips/slip10/App.js +7 -0
- fpythons-0.1.0/slips/slip11/App.js +7 -0
- fpythons-0.1.0/slips/slip12/App.js +7 -0
- fpythons-0.1.0/slips/slip12/index.js +14 -0
- fpythons-0.1.0/slips/slip13/App.js +7 -0
- fpythons-0.1.0/slips/slip13/index.js +14 -0
- fpythons-0.1.0/slips/slip14/App.js +7 -0
- fpythons-0.1.0/slips/slip15/App.js +7 -0
- fpythons-0.1.0/slips/slip16/App.js +7 -0
- fpythons-0.1.0/slips/slip17/App.js +7 -0
- fpythons-0.1.0/slips/slip18/App.js +7 -0
- fpythons-0.1.0/slips/slip19/App.js +7 -0
- fpythons-0.1.0/slips/slip2/App.js +7 -0
- fpythons-0.1.0/slips/slip20/App.js +16 -0
- fpythons-0.1.0/slips/slip21/App.js +7 -0
- fpythons-0.1.0/slips/slip3/App.js +7 -0
- fpythons-0.1.0/slips/slip4/App.js +23 -0
- fpythons-0.1.0/slips/slip5/App.js +18 -0
- fpythons-0.1.0/slips/slip6/App.js +31 -0
- fpythons-0.1.0/slips/slip7/App.js +7 -0
- fpythons-0.1.0/slips/slip8/App.js +7 -0
- fpythons-0.1.0/slips/slip8/src/ToggleButton.js +19 -0
- fpythons-0.1.0/slips/slip9/App.js +7 -0
- fpythons-0.1.0/sync.py +253 -0
fpythons-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: fpythons
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: React (FSD) practical slips: slip-wise code, guides and solved projects
|
|
5
|
+
Requires-Python: >=3.8
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
|
|
8
|
+
# fpythons
|
|
9
|
+
|
|
10
|
+
React (FSD) practical slips (1 to 21): all code slip-wise with folder structure and file paths, guides with commands, explanations and viva questions, plus a solved project for each slip.
|
|
11
|
+
|
|
12
|
+
It covers the React question of each slip, not the Selenium question.
|
|
13
|
+
|
|
14
|
+
## Install
|
|
15
|
+
|
|
16
|
+
```powershell
|
|
17
|
+
python -m pip install fpythons
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Use
|
|
21
|
+
|
|
22
|
+
```powershell
|
|
23
|
+
fpythons # all code, slip by slip (Enter = next, a = all, q = quit)
|
|
24
|
+
fpythons code 8 # code of slip 8 only
|
|
25
|
+
fpythons code --all # all code without pausing
|
|
26
|
+
fpythons txt # save ALL_SLIPS_CODE.txt in the current folder
|
|
27
|
+
fpythons menu # interactive menu
|
|
28
|
+
fpythons list # all slips
|
|
29
|
+
fpythons start # basics: how to write React code
|
|
30
|
+
fpythons show 8 # guide for slip 8
|
|
31
|
+
fpythons get 8 # copy slip 8 project into .\slip8
|
|
32
|
+
fpythons export # copy everything into .\practical-slips
|
|
33
|
+
fpythons viva # viva questions
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
If PowerShell says `fpythons` is not recognized, use `python -m fpythons` instead, for example `python -m fpythons list`.
|
|
37
|
+
|
|
38
|
+
## Use from Python
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
import fpythons
|
|
42
|
+
|
|
43
|
+
print(fpythons.list_slips())
|
|
44
|
+
print(fpythons.get_code(1))
|
|
45
|
+
print(fpythons.get_guide(1))
|
|
46
|
+
fpythons.export_slip(1, "my_folder")
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Running a copied project
|
|
50
|
+
|
|
51
|
+
The package does not include Node.js or `node_modules`. Install Node.js, then:
|
|
52
|
+
|
|
53
|
+
```powershell
|
|
54
|
+
cd slip8
|
|
55
|
+
npm install
|
|
56
|
+
npm start
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Rebuild after changing the code
|
|
60
|
+
|
|
61
|
+
```powershell
|
|
62
|
+
python sync.py
|
|
63
|
+
python -m build
|
|
64
|
+
```
|
fpythons-0.1.0/README.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# fpythons
|
|
2
|
+
|
|
3
|
+
React (FSD) practical slips (1 to 21): all code slip-wise with folder structure and file paths, guides with commands, explanations and viva questions, plus a solved project for each slip.
|
|
4
|
+
|
|
5
|
+
It covers the React question of each slip, not the Selenium question.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```powershell
|
|
10
|
+
python -m pip install fpythons
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Use
|
|
14
|
+
|
|
15
|
+
```powershell
|
|
16
|
+
fpythons # all code, slip by slip (Enter = next, a = all, q = quit)
|
|
17
|
+
fpythons code 8 # code of slip 8 only
|
|
18
|
+
fpythons code --all # all code without pausing
|
|
19
|
+
fpythons txt # save ALL_SLIPS_CODE.txt in the current folder
|
|
20
|
+
fpythons menu # interactive menu
|
|
21
|
+
fpythons list # all slips
|
|
22
|
+
fpythons start # basics: how to write React code
|
|
23
|
+
fpythons show 8 # guide for slip 8
|
|
24
|
+
fpythons get 8 # copy slip 8 project into .\slip8
|
|
25
|
+
fpythons export # copy everything into .\practical-slips
|
|
26
|
+
fpythons viva # viva questions
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
If PowerShell says `fpythons` is not recognized, use `python -m fpythons` instead, for example `python -m fpythons list`.
|
|
30
|
+
|
|
31
|
+
## Use from Python
|
|
32
|
+
|
|
33
|
+
```python
|
|
34
|
+
import fpythons
|
|
35
|
+
|
|
36
|
+
print(fpythons.list_slips())
|
|
37
|
+
print(fpythons.get_code(1))
|
|
38
|
+
print(fpythons.get_guide(1))
|
|
39
|
+
fpythons.export_slip(1, "my_folder")
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Running a copied project
|
|
43
|
+
|
|
44
|
+
The package does not include Node.js or `node_modules`. Install Node.js, then:
|
|
45
|
+
|
|
46
|
+
```powershell
|
|
47
|
+
cd slip8
|
|
48
|
+
npm install
|
|
49
|
+
npm start
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Rebuild after changing the code
|
|
53
|
+
|
|
54
|
+
```powershell
|
|
55
|
+
python sync.py
|
|
56
|
+
python -m build
|
|
57
|
+
```
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"""React (FSD) practical slips: code, guides and solved projects.
|
|
2
|
+
|
|
3
|
+
import fpythons
|
|
4
|
+
fpythons.list_slips()
|
|
5
|
+
print(fpythons.get_code(1))
|
|
6
|
+
print(fpythons.get_guide(1))
|
|
7
|
+
fpythons.export_slip(1, "my_folder")
|
|
8
|
+
"""
|
|
9
|
+
from .main import export_slip, get_code, get_guide, list_slips
|
|
10
|
+
|
|
11
|
+
__version__ = "0.1.0"
|
|
12
|
+
__all__ = ["list_slips", "get_code", "get_guide", "export_slip", "__version__"]
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
# Start here: how to write React code
|
|
2
|
+
|
|
3
|
+
[All slips](README.md) | [Viva](VIVA.md)
|
|
4
|
+
|
|
5
|
+
## 1. Set up your computer (do once)
|
|
6
|
+
|
|
7
|
+
Install Node.js (LTS), then check:
|
|
8
|
+
|
|
9
|
+
```powershell
|
|
10
|
+
node --version
|
|
11
|
+
npm --version
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## 2. Create a project
|
|
15
|
+
|
|
16
|
+
```powershell
|
|
17
|
+
npx create-react-app slip1
|
|
18
|
+
cd slip1
|
|
19
|
+
npm start
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
The app opens at http://localhost:3000/. Stop it with **Ctrl+C**.
|
|
23
|
+
|
|
24
|
+
- `create-react-app` is deprecated by the React team. The solved projects here use it, with `react-scripts` 5.
|
|
25
|
+
- Creating a project and installing packages need internet. Ask your college whether the exam lab has it.
|
|
26
|
+
|
|
27
|
+
## 3. What each file is
|
|
28
|
+
|
|
29
|
+
```text
|
|
30
|
+
slip1/
|
|
31
|
+
package.json packages and scripts
|
|
32
|
+
public/index.html the only HTML page (has <div id="root">)
|
|
33
|
+
src/index.js starts React, shows <App />
|
|
34
|
+
src/App.js main component (edit)
|
|
35
|
+
src/slip1/ YOU CREATE THIS: your components
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## 4. The writing order
|
|
39
|
+
|
|
40
|
+
| Step | What to do |
|
|
41
|
+
|---|---|
|
|
42
|
+
| 1 | `create-react-app`, `cd`, install extra packages |
|
|
43
|
+
| 2 | Redux slips only: slice file, then store file |
|
|
44
|
+
| 3 | Component files |
|
|
45
|
+
| 4 | `App.js`: import and show the component (routes go here) |
|
|
46
|
+
| 5 | Redux slips only: `Provider` in `index.js` |
|
|
47
|
+
| 6 | `npm start` |
|
|
48
|
+
|
|
49
|
+
## 5. Building blocks to memorise
|
|
50
|
+
|
|
51
|
+
### 5.1 Component
|
|
52
|
+
|
|
53
|
+
```jsx
|
|
54
|
+
import React from 'react';
|
|
55
|
+
|
|
56
|
+
const Hello = () => {
|
|
57
|
+
return (
|
|
58
|
+
<div>
|
|
59
|
+
<h2>Hello</h2>
|
|
60
|
+
</div>
|
|
61
|
+
);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export default Hello;
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### 5.2 State and events
|
|
68
|
+
|
|
69
|
+
```jsx
|
|
70
|
+
const [name, setName] = useState('');
|
|
71
|
+
|
|
72
|
+
<input value={name} onChange={(e) => setName(e.target.value)} />
|
|
73
|
+
<button onClick={() => setName('')}>Clear</button>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### 5.3 Form submit
|
|
77
|
+
|
|
78
|
+
```jsx
|
|
79
|
+
const handleSubmit = (e) => {
|
|
80
|
+
e.preventDefault();
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
<form onSubmit={handleSubmit}> ... <button type="submit">OK</button></form>
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### 5.4 Lists
|
|
87
|
+
|
|
88
|
+
```jsx
|
|
89
|
+
<ul>
|
|
90
|
+
{items.map((item, index) => <li key={index}>{item}</li>)}
|
|
91
|
+
</ul>
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### 5.5 Routing (`npm install react-router-dom`)
|
|
95
|
+
|
|
96
|
+
```jsx
|
|
97
|
+
<BrowserRouter>
|
|
98
|
+
<Link to="/about">About</Link>
|
|
99
|
+
<Routes>
|
|
100
|
+
<Route path="/about" element={<About />} />
|
|
101
|
+
<Route path="*" element={<h1>Page Not Found</h1>} />
|
|
102
|
+
</Routes>
|
|
103
|
+
</BrowserRouter>
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### 5.6 Redux Toolkit (`npm install @reduxjs/toolkit react-redux`)
|
|
107
|
+
|
|
108
|
+
```text
|
|
109
|
+
createSlice -> configureStore -> <Provider store> -> useSelector / useDispatch
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## 6. Commands
|
|
113
|
+
|
|
114
|
+
| Command | What it does |
|
|
115
|
+
|---|---|
|
|
116
|
+
| `npm install` | installs everything in `package.json` |
|
|
117
|
+
| `npm install <name>` | adds a package |
|
|
118
|
+
| `npm start` | runs the app |
|
|
119
|
+
| `npm run build` | makes the production build |
|
|
120
|
+
|
|
121
|
+
## 7. Reading an error
|
|
122
|
+
|
|
123
|
+
1. Read the message in the terminal or on the red browser screen.
|
|
124
|
+
2. Find the file name and line number.
|
|
125
|
+
3. Check these usual causes:
|
|
126
|
+
|
|
127
|
+
| Message | Usual cause |
|
|
128
|
+
|---|---|
|
|
129
|
+
| `Module not found` | wrong path or file name, or package not installed |
|
|
130
|
+
| `is not defined` | forgot an `import` |
|
|
131
|
+
| `Adjacent JSX elements must be wrapped` | wrap them in one `<div>` or `<>...</>` |
|
|
132
|
+
| `Too many re-renders` | a function is called in `onClick` instead of passed |
|
|
133
|
+
| Blank page | open the console (F12) and read the first error |
|
|
134
|
+
|
|
135
|
+
## 8. How to practise
|
|
136
|
+
|
|
137
|
+
| Pattern | Learn slip | Then you also know |
|
|
138
|
+
|---|---|---|
|
|
139
|
+
| State and buttons | [3](Slip_03.md) | [8](Slip_08.md), [9](Slip_09.md), [17](Slip_17.md), [16](Slip_16.md) |
|
|
140
|
+
| Forms and inputs | [1](Slip_01.md) | [10](Slip_10.md), [11](Slip_11.md), [14](Slip_14.md), [21](Slip_21.md) |
|
|
141
|
+
| Lists | [19](Slip_19.md) | [7](Slip_07.md), [18](Slip_18.md) |
|
|
142
|
+
| useEffect and useReducer | [2](Slip_02.md) | [15](Slip_15.md) |
|
|
143
|
+
| Routing | [4](Slip_04.md) | [5](Slip_05.md), [6](Slip_06.md), [20](Slip_20.md) |
|
|
144
|
+
| Redux | [13](Slip_13.md) | [12](Slip_12.md) |
|