-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Leanne- NODES #22
base: master
Are you sure you want to change the base?
Leanne- NODES #22
Conversation
Litter PatrolWhat We're Looking For
|
|
||
constructor(props) { | ||
super(props); | ||
this.state = props.state; //change prop state |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would very much never call a prop state
, because it could be confusing. Also you never passed a prop into GameItem
from App
, so props.state
is undefined.
this.clicked = false; | ||
} | ||
|
||
static propTypes = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice that you made this static, but you should also include type
and your callback in the list of props.
onMarkLitterClick = () => { | ||
console.log(this); | ||
//change state here | ||
this.clicked = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should instead do: this.setState( { clicked: true });
console.log(itemType) | ||
if (itemType === "litter") { | ||
this.setState({ | ||
point: this.state.points += 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be points: this.state.points + 1
, plural, not singular, and no assignment.
Litter Patrol
Congratulations! You're submitting your assignment!
Comprehension Questions
this.state
connected?CS Fundamentals Questions
App.render
(it starts withthis.state.items.map
). What is the Big-O time complexity of this code, where n is the number of active game items?setState
-- it must re-render all of the components that now have different content because of that change.What kind of data structure are the components in, and what sort of algorithms would be appropriate for React's code to "traverse" those components?
Speculate wildly about what the Big-O time complexity of that code might be.