組件語法與useState/useEffect
組件語法與基本生
React component (組件)語法
import ReactDOM from "react-dom";
const App = 函式;
//JSX縮寫 直接用()
- // const App = () => (
- // <div>256</div>
- // );
//JSX有變數時 改() => {}
+const App = () => {
+ const count = 256;
+ return (
+ <div>{count}</div>
);
+};
ReactDOM.render(<App />, document.getElementById("root"));props 是什麼
function component [推薦寫法] vs class component
React組件 ES6箭頭函式組件 寫法
State的用法
class(setState) vs function(useState) [推薦寫法]
2.使用function component更改state(用useState)
生命週期
useEffect hook
組件拆分
範例:同檔案拆分

範例:props的傳遞 與解構賦值
範例:分檔案拆分
範例:分檔案拆分:儲存變數
範例:自己造cusomer hook
網路參考範例:
Last updated