Skip to content

Comments

Code-Review#5

Open
ian-antking wants to merge 14 commits intoCommandShiftHQ:masterfrom
Barbarjinks:master
Open

Code-Review#5
ian-antking wants to merge 14 commits intoCommandShiftHQ:masterfrom
Barbarjinks:master

Conversation

@ian-antking
Copy link

No description provided.

import '../styles/app.scss';

class App extends React.Component {
constructor() {
Copy link
Author

Choose a reason for hiding this comment

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

Probably not an issue here as you're not using a Router, but its a good idea to pass props into your constructor and super methods.

country: '',
},
};
this.handleForecastSelect = this.handleForecastSelect.bind(this);
Copy link
Author

Choose a reason for hiding this comment

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

You can do this, but it's easier to define your methods as arrow functions so they bind their own scope.

}

componentDidMount() {
const url = 'https://mcr-codes-weather.herokuapp.com/forecast?city=Bolton';
Copy link
Author

Choose a reason for hiding this comment

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

To make things easier for other developers, we tend to put constants like this into config files. That way anything that need to be customised can all be found in one place.

return (
<React.Fragment>
<LocationDetails
city={this.state.location.city}
Copy link
Author

Choose a reason for hiding this comment

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

This might be a good place for a bit of destructuring. eg:

const { city, country } = this.state.location;

It's a good way to save tying out this.state 100 times.

Copy link
Author

Choose a reason for hiding this comment

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

You can then access the values just by using city and country.

description: PropTypes.string.isRequired,
icon: PropTypes.string.isRequired,
};

Copy link
Author

Choose a reason for hiding this comment

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

Not the end of the world, as this is a personal project, but it would be worth making sure you add propTypes to the rest of your components.


LocationDetails.propTypes = {
city: PropTypes.string.isRequired,

Copy link
Author

Choose a reason for hiding this comment

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

I'd imagine EsLint really doesn't like this blank line here.

import React from 'react';
import PropTypes from 'prop-types';

const LocationDetails = props => <h1 className="location-details">{props.city}, {props.country}</h1>;
Copy link
Author

Choose a reason for hiding this comment

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

Its perfectly valid to use an implicit return like this, but it would be a lot more readable to move your return value down to a new line.

import ForecastSummary from '../../src/components/forecast-summary';

it('renders the date', () => {
const wrapper = shallow((
Copy link
Author

Choose a reason for hiding this comment

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

You can still use the beforeEach hooks with enzyme. In this case it would stop you having to shallow render the same component over and over again.

date="mockDate"

temperature="mockTemperature"

Copy link
Author

Choose a reason for hiding this comment

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

Some odd line spacing here...

Copy link
Author

@ian-antking ian-antking left a comment

Choose a reason for hiding this comment

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

Some really good work here!.

I've added a few comments on how you could get some advanced techniques into you code.

At some point you should change the name of your repository on github to better suit what the actual project is. Be sure to edit your package.json with new author information as well.

If you do use the bootstrap again, you can change the folder it clones into by putting a new name after the url:

git clone git@github.com:MCRcodes/react-bootstrap.git weather-app

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