Skip to content
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

Open
wants to merge 13 commits into
base: codebase-review-empty
Choose a base branch
from

Conversation

JohnWat92
Copy link
Owner

No description provided.

@JohnWat92 JohnWat92 changed the base branch from master to codebase-review-empty April 27, 2017 17:27
Copy link

@10thfloor 10thfloor left a 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';

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;

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;*/

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,

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);

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 });

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);

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.

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.

2 participants