Skip to content

React Homework-嘉義練習生 Johnny Yu#3

Open
johnnyyu0930 wants to merge 9 commits intoclonn:masterfrom
johnnyyu0930:master
Open

React Homework-嘉義練習生 Johnny Yu#3
johnnyyu0930 wants to merge 9 commits intoclonn:masterfrom
johnnyyu0930:master

Conversation

@johnnyyu0930
Copy link

  1. Todo list
  2. movie search

Copy link
Owner

@clonn clonn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感覺對於 react 已經有熟悉度,
對於套件有基本使用觀念。

可以思考一下如何將 component 拆解,讓每個元件的關係更為獨立。

README.md Outdated
and you can build with no-minify or no-cache
or

$ yan run build
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yarn?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OH 打太快了@@ 是yarn

package.json Outdated
"react": "16.x",
"react-dom": "^16.8.0",
"react-router-dom": "^5.0.0",
"regenerator-runtime": "^0.13.2"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

這個部分是?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

之前 npm start 的時候 一直跳出找不到regenerator-runtime
然後我就重裝就正常了 不知道什麼原因

剛剛把它拿掉又可以動了~

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可能因為是採用 yarn 安裝的關係,兩者機制上會不太一樣。

src/app.js Outdated
isloader: false,
isGet: true
})
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果這部分要處理例外處理,建議將 if 判斷,改採用 try catch 的方式,

const src = `https://www.imdb.com/title/${id}`;

return (
<tr onClick={(e) => openSite(e, src)}>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

這邊用 onClick 的部分,採用 window.open , 這樣可能需要考慮會被瀏覽器預設開新視窗擋住。

建議還是用 只是將 a 的範圍,延伸到整個 tr 區塊即可。

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好的

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

剛剛試過用a包 tr React 會跳warning

import Button from '@material-ui/core/Button';

const SearchBar = ({ ...props }) => {
const [keyword, setKeyword] = React.useState(props.keyword);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

React.useState(props.keyword);

會建議直接改採用

import {useState} from "react";
// 這邊已經將 ...props, 理論上可以直接使用 keyword, 如果怕遇到問題可以這樣用,
const [keyword, setKeyword] = React.useState(keyword || '');

Copy link
Author

@johnnyyu0930 johnnyyu0930 Jun 4, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// 這邊已經將 ...props, 理論上可以直接使用 keyword, 如果怕遇到問題可以這樣用

我試過直接使用keyword 他會找不到
發現他是把其他屬性放進去 props裡面

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以確認一下一開始進入的時候, 最外層所帶入的 props 到底代表什麼物件,這樣會耕清楚為何會導致 useState 會出現問題喔~

有時間可以試試看

const MovieList = ({ movies, ...props }) => {
return (
<div>
<SearchBar {...props}/>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

建議將 SearchBar 與 MovieList 獨立開來

兩者基本上是可以視為獨立元件,這樣也可以讓事件都是獨立傳送, SearchBar 才不會跟 movie list 的耦合度太高

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

了解 謝謝

@johnnyyu0930
Copy link
Author

johnnyyu0930 commented Jun 4, 2019

code review後 已經把修改部分pull request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants