Skip to content

Alex.Gaw.Austin1#5

Open
alexjgaw wants to merge 23 commits intoAustinCodingAcademy:masterfrom
alexjgaw:master
Open

Alex.Gaw.Austin1#5
alexjgaw wants to merge 23 commits intoAustinCodingAcademy:masterfrom
alexjgaw:master

Conversation

@alexjgaw
Copy link

Contact list

Copy link
Contributor

@ivome ivome left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job on the implementation!

You might be interested in a CSS coding style guide:
https://smacss.com/

src/Contact.js Outdated
occupation: PropTypes.string.isRequired,
onRemove: PropTypes.function.isRequired,
_id: PropTypes.number.isRequired
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job with the PropTypes!

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had been confused on why I was getting PropTypes linter errors, looking at your code helped me understand how to validate them, thank you again :D

src/App.js Outdated

handleSearchBarChange(event) {
this.setState({
contacts: this.state.contacts,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is not needed, since you are reassigning the same value.

Copy link

@chrisperk chrisperk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great stuff, Alex! I learned a lot reviewing your code, thank you! And I didn't see any errors.

src/App.js Outdated
import ContactList from './ContactList';
import SearchBar from './SearchBar.js';

/* eslint max-len: [1, {"ignoreUrls": true}] */

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great find, thank you for sharing this rule!

src/Contact.js Outdated
occupation: PropTypes.string.isRequired,
onRemove: PropTypes.function.isRequired,
_id: PropTypes.number.isRequired
};

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had been confused on why I was getting PropTypes linter errors, looking at your code helped me understand how to validate them, thank you again :D


return (
<div className="selected-contact">
<h1>{props.contacts.length > 0 ? 'Selected contacts' : 'No contacts selected'}</h1>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really cool! I was trying to figure out how to do this for like hours.

Copy link

@michaeb michaeb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Alex, I like how you changed some of the components to functional ones. I also looked through and it looks like you're careful not to mutate your state too, nicely done.

Copy link
Contributor

@ivome ivome left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really great implementation!! Clean code and great functionality. Keep it up!!

@@ -0,0 +1,54 @@
import React, { Component, PropTypes } from 'react';

class Action extends Component {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be careful with the naming when using such words. An action usually refers to an actual action in software. So maybe ActionHistoryItem would be more descriptive.

return (
<div className="side-bar action-history">
<h3>Action History</h3>
{props.actions.length > 0 ? null : 'Perform an action, jagweed.'}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When checking if an array has items, you can use the shorthand and just write props.actions.length ? null : '...' Since length returns a truthy value when there is items in the array.

{props.actions.length > 0 ? null : 'Perform an action, jagweed.'}
<div className="side-bar-scroll">
<ul className="action-list">
{props.actions.slice(0, 10).map(action => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of keeping all history items in memory, you could also implement the limit when adding items to the queue. If you have more than 10 items right now and then remove some, the old items reappear. Since we have the expiration time, it's not that big of a deal, otherwise you would have a memory leak in your application and that action history could grow endlessly.

src/App.js Outdated
}, 1000);
})
.catch(error => {
console.log(error);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idea: Implement some error handling in the UI. console.log will break in IE.

src/App.js Outdated
newState[key] = list.filter( contact => contact._id !== id);

this.setState(newState);
return newState;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could simplify this with ES6:

this.setState({
  [key]: list.filter( contact => contact._id !== id)
});

background-color: #99cfff;
}

}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be cleaner to have the styles in the css files of the components.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants