-
Notifications
You must be signed in to change notification settings - Fork 126
Ada pets api solution #3
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
base: ada-pets-api
Are you sure you want to change the base?
Conversation
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", |
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 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.)
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.
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, |
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 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.)
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 used for filtering.
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 did change the name however to fullList
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 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?
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 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
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.
^ This would involve lifting the state out of search bar.
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.
@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.
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've updated it to lift the search form's state up.
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.
Cool :)
|
I have that one comment but other than that, looks good to me :) |
c455313 to
67cfcc6
Compare
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.