-
Notifications
You must be signed in to change notification settings - Fork 43
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
React random colors #23
base: master
Are you sure you want to change the base?
Conversation
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.
Hi @vikisimovska I'd like you to refactor this a bit to do away with the Boxes component and generate the array from 1 to 24 more programmatically.
super(props); | ||
|
||
this.state = { | ||
numbers : [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24] |
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.
😩
Array(24).fill(0).map((e, i) => i + 1);
😄
this.setState({ | ||
numbers : newArr | ||
}) | ||
}, 300); |
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.
what is 300
supposed to do here?
@@ -0,0 +1,12 @@ | |||
import React, { Component } from 'react'; | |||
|
|||
class Box extends Component{ |
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.
since there's no state it is preferable to use a stateless functional component
import React, { Component } from 'react'; | ||
import Box from './box'; | ||
|
||
class Boxes extends Component{ |
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.
having this Boxes
component is a bit of an anti-pattern. You don't really need a component whose only purpose is to render x number of a different component.
|
||
render(){ | ||
const boxList = this.props.numbers.map((num, idx) => { | ||
return( |
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 move this logic into <App />
Adding solution for Random Colors.