Skip to content

React homework - 嘉義 Amy Hsieh#6

Open
amyhsieh16 wants to merge 1 commit intoclonn:masterfrom
amyhsieh16:master
Open

React homework - 嘉義 Amy Hsieh#6
amyhsieh16 wants to merge 1 commit intoclonn:masterfrom
amyhsieh16:master

Conversation

@amyhsieh16
Copy link

hw finish

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 hook 的模式,直接用 function 成為 component,
此架構下,可以再將前面的 state 的部分,改為 useState 可以有更多樂趣。


render() {
const { todos } = this.state;
const { movie } = this.state;
Copy link
Owner

Choose a reason for hiding this comment

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

這兩行可合併為一行,

const { movie, todos } = this.state;

return (
<MoiveInfo key = {index} {...movie}/>
)
})
Copy link
Owner

Choose a reason for hiding this comment

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

Object.values(movies).map(function(movie, index){

可以改寫為,

Object.values(movies).map((movie, index) => {

Copy link
Owner

Choose a reason for hiding this comment

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

這邊的 movies 應該是 array , 可以直接使用

movies.map( (movie. index) => 

Object.values(todos).map(function(todo, index){
return <List key = {index} {...todo}/>
})
}
Copy link
Owner

Choose a reason for hiding this comment

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

todos 是 array 可以不用 object.keys 而是可以直使用

todos.map((todo, idx) => {

@@ -0,0 +1,17 @@
import React from 'react'
Copy link
Owner

Choose a reason for hiding this comment

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

這邊的 React 可以拿掉

Copy link
Author

Choose a reason for hiding this comment

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

試著拿掉,會出現錯誤碼,無法呈現畫面

@@ -0,0 +1,14 @@
import React from 'react'
Copy link
Owner

Choose a reason for hiding this comment

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

React 可以拿掉

Copy link
Author

Choose a reason for hiding this comment

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

試著拿掉,但會出現錯誤碼,無法呈現畫面

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