-
Notifications
You must be signed in to change notification settings - Fork 0
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
Codebase review project #1
base: codebase-review-empty
Are you sure you want to change the base?
Conversation
13116e6
to
79e4bd9
Compare
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 job. I've looked at your project since this submission and I'm encouraged by your progress.
The best way to get used to using React & Redux is to practice and repeat.
import FlatButton from 'material-ui/FlatButton'; | ||
import styles from './styles.css'; | ||
import { sortNewest, sortPopular } from '../../redux/actions'; | ||
|
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.
Grouping related imports will help you stay organised. Decide how you're going to group and make sure you're consistent across all files
eg. In this file:
import React from 'react';
import { connect } from 'react-redux';
import { sortNewest, sortPopular } from '../../redux/actions';
import { Toolbar, ToolbarTitle } from 'material-ui/Toolbar';
import FlatButton from 'material-ui/FlatButton';
import styles from './styles.css';
} | ||
} | ||
|
||
export default Week; |
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.
Nice job on this component. Separating your .map
functions into Class Methods is the way to go.
color: red; | ||
font-family: Roboto, sans-serif; | ||
padding-left:255px; | ||
/*margin: 1rem;*/ |
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.
Remove all commented code from your project submissions.
this.sortPopular = this.sortPopular.bind(this); | ||
this.sortNewest = this.sortNewest.bind(this); | ||
this.state = { | ||
posts: data.posts, |
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 know we refactored this together, but please ensure you remove all local state from your components, when using Redux.
} | ||
} | ||
const mapStateToProps = (state) => ( { posts: state.posts }); | ||
export default connect(mapStateToProps)(PostListContainer); |
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.
You mapped the same state to a parent & child component (PostListContainer.js
& PostList.js
). This is not necessary. Map state to the component that needs it. Try not to pass state down as a prop on a component, unless absolutely necessary. Be careful not to map the same state to parent & child components as this could cause unnecessary re-rendering of your component tree and is generally redundant and confusing.
export const updateVote = id => ({ type: UPDATE_VOTE, id }); | ||
export const sortNewest = posts => ({ type: SORT_NEWEST, posts }); | ||
export const sortPopular = posts => ({ type: SORT_POPULAR, posts }); | ||
|
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.
It's not necessary to pass in posts
to your sorting action creators. (sortNewest
& sortPopular
) You can access state.posts
inside the reducer. Action creators don't always need an argument and actions don't always need to have a payload. Sometimes it's simpler if they're just actions with a type, like in this case. Please refactor your action creators.
console.log(' sorting newest', state); | ||
console.log('state', state); // gives me the right thing | ||
console.log('this', this); //undefined | ||
// console.log('this.state', this.state); |
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.
Please remove all console.log's and comments from submitted projects.
No description provided.