-
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
Anibel - Edges Inspiration Board #19
base: master
Are you sure you want to change the base?
Conversation
Inspiration BoardWhat We're Looking For
|
|
||
this.state = { | ||
cards: [], | ||
url: this.props.url, | ||
boardName: this.props.boardName, |
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.
If the URL and board name aren't going to be changed within this component, you don't need to keep them in state
. If you read them from props
throughout the app, it will be more clear that they're read-only.
const POST_INSPO_CARDS_URL = this.props.url + '/' + this.props.boardName + '/cards'; | ||
axios.post(POST_INSPO_CARDS_URL, cardData) | ||
.then((response) => { | ||
cardData.id = response.data.card.id; |
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 like that you've kept all the API interaction logic in one component - the callbacks are a little more complex, but I would say it makes the app as a whole much easier to comprehend. Whether or not you intended it, this is a great example of the container component pattern well-applied.
resetState = () => { | ||
this.setState({ | ||
text: '', | ||
emoji: '' |
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.
Good use of a helper method here. Could you call this from your constructor instead of repeating this work?
Inspiration Board
Congratulations! You're submitting your assignment!
Comprehension Questions
NewCardForm
component. Upon submission, these states are sent up to anewCard
method in theBoard
component via a callback. The method posts a requests to the API and a new card is either successfully created or errors are stored in state. If the card is successfully created, theBoard
's card state is updated with the new card.componentDidMount()
to get the list of cards from the API so that I can set the state and rerender the component within that lifecycle.