Skip to content

Here is Liuliu.#7

Open
Chiaminliu wants to merge 18 commits intoclonn:masterfrom
Chiaminliu:master
Open

Here is Liuliu.#7
Chiaminliu wants to merge 18 commits intoclonn:masterfrom
Chiaminliu:master

Conversation

@Chiaminliu
Copy link

This work is very interesting.

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.

有思考到架構的部分,還有如何拆解的方向,
裡面有指出一些方向,可以多參考一下~

module.exports = {
async requestMovieInfo (search = "Batman") {
let {data : info} = await axios.get(`http://www.omdbapi.com/?s=${search}&apikey=34472924`)
return info
Copy link
Owner

Choose a reason for hiding this comment

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

如果沒有要重複給值的話,建議可以用 const 做宣告

Copy link
Author

Choose a reason for hiding this comment

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

如果沒有要重複給值的話,建議可以用 const 做宣告

了解~ 想請問 let 和 const有性能或其他方面上的差異嗎?

src/app.js Outdated
}

async searchKwd (kwd) {
if (!kwd) kwd = "banana";
Copy link
Owner

Choose a reason for hiding this comment

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

給個建議, kwd 縮寫固然好,對於易讀性來說,還是直接取名字為 keyword 會更為直接容易閱讀

Copy link
Author

Choose a reason for hiding this comment

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

好唷

if (this.state.showPage == "todo") {
show = <Todo todos = {todos} />
}

Copy link
Owner

Choose a reason for hiding this comment

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

建議會將這一大段拉出來成為一個 function 或者一個 Show component 來處理, 這樣在閱讀的時候會更為輕鬆容易

Copy link
Author

Choose a reason for hiding this comment

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

確實是這樣,我改好了!

)
})}
</div>);
} else return <div>Waiting...</div>
Copy link
Owner

Choose a reason for hiding this comment

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

可以這樣子寫

{
  (movies.Search) ? 
  return (<div> ... ) : 
  return <div>Waiting...</div>
}

Copy link
Author

Choose a reason for hiding this comment

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

照著修改有碰到一點小問題,把三元運算子放到 return內後解決,不過感覺上變得有點不好閱讀

bindCheckBox (inputId) {
const input = document.getElementById(inputId)
input.checked = !input.checked
}
Copy link
Owner

Choose a reason for hiding this comment

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

會將 input.checked 這個部分,直接從外部帶進來,變成

this.state.checked

處理的時候直接就可以進行

this.setState({
  checked: !checked
})

底下的 checkbox checked 就可以跟著 this.state.checked 的數值直接輸出即可,就不用使用 getElementBy ...

Copy link
Author

Choose a reason for hiding this comment

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

checked

如果是 list 這種動態產生的 checkbox,如何用這個方法來改寫呢?
我想到的方法要根據 list id 建立對應的 state 才能做,不知道有什麼更好的方法嗎?

}
.hoverZoom:hover {
zoom : 1.5;
} No newline at end of file
Copy link
Owner

Choose a reason for hiding this comment

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

這邊用到了些 transform, 也不是不好不過如果只是要拿來做定位使用的話, transform 會使用到不少效能,盡量在如果是要對應座標,應該在父結點上面設定上去 position: relative;

If the variable doesn't reassign, suggest to declare to const.
Refactoring code in app.js to improve readability.
From kwd to keyword.
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