Skip to content

Conversation

@CheezItMan
Copy link
Contributor

Warning DO NOT MERGE

This is to allow instructors to review the solution for the two API exercises. Take a look and let me know any changes that need to be made.

package.json Outdated
"scripts": {
"start": "react-scripts start",
"server": "json-server --watch src/data/pets.json",
"server": "json-server --watch src/data/pets.json --port 2999",
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't love changing the port this runs on since it will run on port 3000 in Heroku. For the solution I'd rather change the port that the node server runs on. (It looks like you're making calls to localhost:2999.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I can change the node server to run on 2999 and let json server run on 3K

src/App.js Outdated
.then((response) => {
this.setState({
petList: response.data,
originalPets: response.data,
Copy link
Contributor

Choose a reason for hiding this comment

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

I know you didn't add it but what do we use originalPets for that we couldn't just use petList for? (Since it looks like you're setting originalPets every time you set petList.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's used for filtering.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did change the name however to fullList

Copy link
Contributor

Choose a reason for hiding this comment

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

I was actually just reading about how this is an antipattern according to react documentation.
It's storing more data in state than needs to be stored, cause it could just be storing the filter term in state, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

That said, I know it was already like this so maybe that's out of scope for this change.
The thing I read was step 3 here: https://reactjs.org/docs/thinking-in-react.html

Copy link
Contributor

Choose a reason for hiding this comment

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

^ This would involve lifting the state out of search bar.

Copy link
Contributor Author

@CheezItMan CheezItMan Dec 6, 2019

Choose a reason for hiding this comment

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

@jmaddox19
You're right in that we should instead be lifting state out of the search bar and then using that term to filter the prop passed into the PetList.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've updated it to lift the search form's state up.

Copy link
Contributor

Choose a reason for hiding this comment

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

Cool :)

@jmaddox19
Copy link
Contributor

I have that one comment but other than that, looks good to me :)

@CheezItMan CheezItMan force-pushed the ada-pets-api-solution branch from c455313 to 67cfcc6 Compare December 6, 2019 20:40
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.

4 participants