Open
Conversation
clonn
reviewed
Jun 3, 2019
Owner
clonn
left a comment
There was a problem hiding this comment.
後面的使用方式採用 react hook 的模式,直接用 function 成為 component,
此架構下,可以再將前面的 state 的部分,改為 useState 可以有更多樂趣。
|
|
||
| render() { | ||
| const { todos } = this.state; | ||
| const { movie } = this.state; |
Owner
There was a problem hiding this comment.
這兩行可合併為一行,
const { movie, todos } = this.state;
| return ( | ||
| <MoiveInfo key = {index} {...movie}/> | ||
| ) | ||
| }) |
Owner
There was a problem hiding this comment.
Object.values(movies).map(function(movie, index){
可以改寫為,
Object.values(movies).map((movie, index) => {
Owner
There was a problem hiding this comment.
這邊的 movies 應該是 array , 可以直接使用
movies.map( (movie. index) =>
| Object.values(todos).map(function(todo, index){ | ||
| return <List key = {index} {...todo}/> | ||
| }) | ||
| } |
Owner
There was a problem hiding this comment.
todos 是 array 可以不用 object.keys 而是可以直使用
todos.map((todo, idx) => {
| @@ -0,0 +1,17 @@ | |||
| import React from 'react' | |||
| @@ -0,0 +1,14 @@ | |||
| import React from 'react' | |||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
hw finish