-
Notifications
You must be signed in to change notification settings - Fork 12
Conversation
Update from original
src/QuestionViewer/index.js
Outdated
(<div> | ||
<a class="button float-left" href={prev}>Prev</a> | ||
<a class="button float-right" href={nxt}>Next</a></div>) | ||
} |
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 could be done much more neatly.
<div>
{qno !== 1 && .....prev....}
{qno !== 5 && .....next....}
</div>
src/QuestionViewer/index.js
Outdated
res = await res.json(); | ||
if (!res.error) this.setState({ question: res, loading: false }) | ||
else this.setState({ error: res.error, loading: false }) | ||
} | ||
render() { | ||
const { loading, question, error } = this.state | ||
const quesno = parseInt(this.props.params.qno,10) |
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.
Name it as qno
please for consistency
src/QuestionViewer/index.js
Outdated
res = await res.json(); | ||
if (!res.error) this.setState({ question: res, loading: false }) | ||
else this.setState({ error: res.error, loading: false }) | ||
} | ||
render() { | ||
const { loading, question, error } = this.state | ||
const quesno = parseInt(this.props.params.qno,10) | ||
const prev = `/question/${quesno-1}` | ||
const nxt = `/question/${quesno+1}` |
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.
No need to define as you will use them only once if you code it like I suggested. However your choice.
src/QuestionViewer/index.js
Outdated
} | ||
{ | ||
qno!==5 && | ||
<a class="button float-right" href={`/question/${qno+1}`}> |
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.
use Link
component instead of a
like we do in navbar
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.
Difference is this will not cause the page to reload
No description provided.