Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Details.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Details extends React.Component {
state = { loading: true, showModal: false };
componentDidMount() {
pet
.animal(this.props.id)
.animal(parseInt(this.props.id))

Choose a reason for hiding this comment

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

Don't forget the radix. You want to make sure that it gets parse to base 10.

parseInt(this.props.id, 10)

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt

And actually in this case, I believe it would be more appropriate to use Number()

Number(this.props.id)

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number

Choose a reason for hiding this comment

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

What you say sounds good. @btholt What do you think ?

In case you decide by Number I modify it

.then(({ animal }) => {
this.setState({
url: animal.url,
Expand Down Expand Up @@ -82,4 +82,4 @@ export default function DetailsErrorBoundary(props) {
<Details {...props} />
</ErrorBoundary>
);
}
}