javascript
- JavaScript | MDN
- 介紹 DOM 及事件流程
- 深入現代前端開發
- JavaScript 核心篇
- 重新認識 JavaScript
- JavaScript基本功修煉
- Basic
- single thread
- Hoisting
- 優點在於程式碼可以在該宣告之前被呼叫以及使用
- 函式比變數有更高的優先權(僅限於函式陳述式, 函式表達式不理這一套)
- No failure fast
- 匿名函式
- undefined / not defined 差異
- 當一個變數沒有被賦予任何值,JavaScript會自動賦予undefined
- 陣列
- BOM
- Advance
- closure
- 函式工廠
- closure
- ES6
- let & const
- 出現前,不少開發者都會用立即函式來避免汙染到全域變數
- 箭頭函式 - Arrow function
- 注意this
- 解構賦值
- Promise
- let & const
- 和其他資料源拿
nodejs
react
- “Every React Concept Explained in 12 Minutes
- 用 12 分鐘的時間先大致認識一下 React 重要的觀念以及功能,包含 Components, JSX, Props, Children, State, Hooks, Refs, Context, Effects 等等,這些都是開發 React 應用會用到的工具
- 學習指南:React 介紹 – React
- 終究都要學 React 何不現在學呢? - 鐵人賽後記 - 目錄 - (30) | 是 Ray 不是 Array
- 給初入JS框架新手的React.js入門 :: 第 11 屆 iThome 鐵人賽
- 從比入門再往前一點開始,一直到深入React.js :: 第 12 屆 iThome 鐵人賽
- 一次打破 React 常見的學習門檻與觀念誤解 :: 2022 iThome 鐵人賽
- Building Full Stack Applications With Python and ReactJS - YouTube
- A GUI tool to build your react app in the fastest way with all components
- Create a GUI for Python using React | by Code Review Doctor | Medium
- A Python developer's guide to React - LogRocket Blog
- UI Componets
- React Material UI Tutorial - YouTube
- Material-UI Grid Tutorial and Examples | React.School
- shadcn UI
- The Most Popular React UI Component Libraries in 2022 - SitePoint
- React UI Components Libraries: Our Top Picks for 2023
- 20+ Best React UI Component Libraries / Frameworks for 2023
- Tailwind CSS 到底是良藥還是毒藥? | Summer。桑莫。夏天
- IDE
concept
- JSX: html in js
- React 針對 JavaScript 所出的擴充語法
- 是一種語法糖
- 瀏覽器並不懂什麼叫做 JSX
- key的影響
- 表達式 (Expression)
- JavaScript 核心觀念(11)-運算子、型別與文法-陳述式與表達式 | 是 Ray 不是 Array
- :x: 無法在 JSX 中撰寫 if...else 判斷式
- :heavy_check_mark: 三元運算子
- :heavy_check_mark: 自動展開陣列內容
- HTML Style 就要注意 JSX 採用的是 camelCase 撰寫方式
- class 變成 className
- Class Component(早期寫法): 使用 ES6 的 Class 語法來建立
- Function Component(after Class Component): 比 Class Component 簡潔許多
- React Hooks: React 16.8 新增的功能,而它主打的就是你不用再寫 class 就可以直接使用 React 相關功能
- Hooks API Reference – React
- 使用規則
- 只能在函式頂層使用
- 只能用於 Function Component
- 基於 Function Component 所設計的,因此就只能在 Function Component 中使用,是不能在 Class Components 中使用的
- React State
- State Hook
- useState 函式會回傳一個陣列
- 使用 陣列解構 取出兩個變數,第一個變數會作為渲染顯示用、單純的資料,第二個則是告知 React 資料有變化,所以要重新 re-render
- 觸發畫面重新渲染的關鍵 Hook
- 可以傳入各式各樣的型別
- 陣列跟物件
- Side Effect
- useEffect
- 主要大多用途都是在於我們畫面 render 之後要做某些事情
- ex. AJAX 行為、修改 DOM 操作
- 行為
- After Ever Render
- Once
- On State
- cleanup function
- 時機只有在你觸發重新渲染畫面時才會被呼叫一次
- 適合用於初始化狀態或者清除特定的事件綁定 -使用 Props 將資料往下傳遞, 傳遞太深
- 主要大多用途都是在於我們畫面 render 之後要做某些事情
- useContext
- 主要大多用於跨元件溝通的技巧
- 只能接受 Context Object
- useEffect
- 事件處理
- React 事件處理寫法與與 「Inline events」 有高度的 87% 神似
on+[事件名稱]={ 函式 }
- 事件名稱首字會是大寫且採用 camelCase 方式
- SyntheticEvent – React
- Component
- 模組化的概念
- 巢狀結構
- Props: Component之間的資料交換
- 單向數據流
- OnlyRead (唯讀)
- 單向數據流
Redux
docker with mui
Dockerfile
FROM node:latest
RUN npx create-react-app main
WORKDIR /main
RUN yarn add @mui/material @emotion/react @emotion/styled && yarn add @fontsource/roboto && yarn add @mui/icons-material
EXPOSE 3000
ENTRYPOINT ["npm", "start"]
docker-compose.yml ``` yml= version: '3'
services: react-mui: container_name: react-mui build: context: . image: react-mui working_dir: /main ports: - "3000:3000"
src/APP.js ``` javascript= import logo from './logo.svg'; import './App.css'; import Board from './Board'; import Notification from './Notification';
function App() { return (
); }export default App;
src/Board.js
``` javascript=
import React from 'react';
import Table from '@mui/material/Table';
import TableBody from '@mui/material/TableBody';
import TableCell from '@mui/material/TableCell';
import TableContainer from '@mui/material/TableContainer';
import TableHead from '@mui/material/TableHead';
import TableRow from '@mui/material/TableRow';
import Paper from '@mui/material/Paper';
import Button from '@mui/material/Button';
class Board extends React.Component {
constructor(props) {
super(props);
this.state = {
rows: [
this.createData('Frozen yoghurt', 159, 6.0, 24, 4.0),
this.createData('Ice cream sandwich', 237, 9.0, 37, 4.3),
this.createData('Eclair', 262, 16.0, 24, 6.0),
this.createData('Cupcake', 305, 3.7, 67, 4.3),
this.createData('Gingerbread', 356, 16.0, 49, 3.9),
],
};
}
createData(name, calories, fat, carbs, protein) {
return { name, calories, fat, carbs, protein };
}
handleClick() {
const rows = this.state.rows.slice();
rows.push(this.createData('Test', 356, 16.0, 49, 3.9))
this.setState({rows: rows});
}
render() {
return (
<TableContainer component={Paper}>
<Table sx={{ minWidth: 650 }} aria-label="simple table">
<TableHead>
<TableRow>
<TableCell>Dessert (100g serving)</TableCell>
<TableCell align="right">Calories</TableCell>
<TableCell align="right">Fat (g)</TableCell>
<TableCell align="right">Carbs (g)</TableCell>
<TableCell align="right">Protein (g)</TableCell>
</TableRow>
</TableHead>
<TableBody>
{this.state.rows.map((row) => (
<TableRow
key={row.name}
sx={{ '&:last-child td, &:last-child th': { border: 0 } }}
>
<TableCell component="th" scope="row">
{row.name}
</TableCell>
<TableCell align="right">{row.calories}</TableCell>
<TableCell align="right">{row.fat}</TableCell>
<TableCell align="right">{row.carbs}</TableCell>
<TableCell align="right">{row.protein}</TableCell>
</TableRow>
))}
</TableBody>
</Table>
<Button variant="contained" onClick={() => this.handleClick()} >Submit</Button>
</TableContainer>
);
}
}
export default Board;
src/Notification.js ``` javascript= import * as React from 'react'; import Badge from '@mui/material/Badge'; import MailIcon from '@mui/icons-material/Mail';
export default function SimpleBadge() {
return (