Conversation
johnnyyu0930
commented
Jun 2, 2019
- Todo list
- movie search
clonn
left a comment
There was a problem hiding this comment.
感覺對於 react 已經有熟悉度,
對於套件有基本使用觀念。
可以思考一下如何將 component 拆解,讓每個元件的關係更為獨立。
README.md
Outdated
| and you can build with no-minify or no-cache | ||
| or | ||
|
|
||
| $ yan run build |
package.json
Outdated
| "react": "16.x", | ||
| "react-dom": "^16.8.0", | ||
| "react-router-dom": "^5.0.0", | ||
| "regenerator-runtime": "^0.13.2" |
There was a problem hiding this comment.
之前 npm start 的時候 一直跳出找不到regenerator-runtime
然後我就重裝就正常了 不知道什麼原因
剛剛把它拿掉又可以動了~
src/app.js
Outdated
| isloader: false, | ||
| isGet: true | ||
| }) | ||
| } |
There was a problem hiding this comment.
如果這部分要處理例外處理,建議將 if 判斷,改採用 try catch 的方式,
| const src = `https://www.imdb.com/title/${id}`; | ||
|
|
||
| return ( | ||
| <tr onClick={(e) => openSite(e, src)}> |
There was a problem hiding this comment.
這邊用 onClick 的部分,採用 window.open , 這樣可能需要考慮會被瀏覽器預設開新視窗擋住。
建議還是用 只是將 a 的範圍,延伸到整個 tr 區塊即可。
src/components/SearchBar.js
Outdated
| import Button from '@material-ui/core/Button'; | ||
|
|
||
| const SearchBar = ({ ...props }) => { | ||
| const [keyword, setKeyword] = React.useState(props.keyword); |
There was a problem hiding this comment.
React.useState(props.keyword);
會建議直接改採用
import {useState} from "react";
// 這邊已經將 ...props, 理論上可以直接使用 keyword, 如果怕遇到問題可以這樣用,
const [keyword, setKeyword] = React.useState(keyword || '');
There was a problem hiding this comment.
// 這邊已經將 ...props, 理論上可以直接使用 keyword, 如果怕遇到問題可以這樣用
我試過直接使用keyword 他會找不到
發現他是把其他屬性放進去 props裡面
There was a problem hiding this comment.
可以確認一下一開始進入的時候, 最外層所帶入的 props 到底代表什麼物件,這樣會耕清楚為何會導致 useState 會出現問題喔~
有時間可以試試看
src/containers/MovieList.js
Outdated
| const MovieList = ({ movies, ...props }) => { | ||
| return ( | ||
| <div> | ||
| <SearchBar {...props}/> |
There was a problem hiding this comment.
建議將 SearchBar 與 MovieList 獨立開來
兩者基本上是可以視為獨立元件,這樣也可以讓事件都是獨立傳送, SearchBar 才不會跟 movie list 的耦合度太高
|
code review後 已經把修改部分pull request |