-
Notifications
You must be signed in to change notification settings - Fork 26
Conversation
} | ||
|
||
.mainSection { | ||
padding: .5em; |
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.
best practice to use rem for spacing.
Actually, you generally want to stay away from em
unless you have a very good / specific reason to use it...such as some sort of font based thing.
); | ||
}; | ||
|
||
PopUpCard.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.
We can refactor this later if you want, but it's probably more helpful to assume nothing about the API giving the data in the component, and ask for props exactly as it would be helpful to render them.
For example, you may want to ask for an object like:
shipment: {
location: 'City, State',
lastUpdated: 'time',
eta: 'time',
orderId: 123,
status: 'pending',
}
and then, also we want to do a full prop validation for the object coming in. Here is how I did it for the role switcher:
RoleItem.propTypes = {
user: React.PropTypes.shape({
id: React.PropTypes.number.isRequired,
role: React.PropTypes.string.isRequired,
location: React.PropTypes.string,
loggedIn: React.PropTypes.bool,
}),
roleAction: React.PropTypes.func.isRequired,
};
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.
That's how I had it before, but then changed it like this because it was adding a lot of parsing logic to the parent component (Dashboard)....
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.
yea that's fine, it's why I mentioned we can refactor later. Ideally the wrapper component, or the reducer holding the state would be doing all of this logic, which doesn't exist yet.
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.
The main idea, or way of thinking is to keep all business logic outside of the view components of the app, such that as the app grows and multiple pieces may need to consume that data it's not being reproduced everywhere.
The other benefit, is that if...say we wanted to build a React Native app later...that React Native app would easily be able to consume all of our reducers and other logic...and all they had to do was build some new views that are specific to Ios or android etc.
Another thing you might add, is a |
Okay I'm ready to merge this. Another thing that might help in future pull requests is to toss in a screenshot and/or gif of what you added if it's a visual component. Not a big deal, just easier to review. |
No description provided.