liftedpixel / jammming

a Codecademy React project
http://jammmmmmmmmmmming.surge.sh
0 stars 0 forks source link

Saving playlist #3

Closed ghost closed 6 years ago

ghost commented 6 years ago

https://github.com/liftedpixel/jammming/blob/master/src/components/App/App.js#L38-L39

When you save a playlist, the playlistTracks and playlistName should both be reset. searchResults should probably not be reset since the search could still be useful to the next playlist.

However, it is considered a poor practice for a React class method to use this.setState more than once. Instead of calling this.updatePlayListName, you should just update all state in a single this.setState.

https://github.com/liftedpixel/jammming/blob/master/src/components/Playlist/Playlist.js#L19

Rather than using a defaultValue attribute, just use a value attribute. And instead of giving it a value of {'New Playlist'}, you should use {this.props.name} which is getting passed down from the App component. That way the value of the form will always reflect what is passed down via props and you can properly reset the playlistName value.

liftedpixel commented 6 years ago

I cleaned both of these up, but I forgot to mention it in the commit to make it auto close.