-
Notifications
You must be signed in to change notification settings - Fork 1
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
Brandon buggy interview question #12
base: master
Are you sure you want to change the base?
Conversation
|
||
constructor(props) { | ||
super(props); | ||
this.svgWidthPx = 300; |
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.
Not a bug but the candidate should point out that the graph isn't responsive and may be cut off on different mobile devices
heartRateToY(heartRate) {...} // implementation elided for brevity | ||
|
||
refreshCardiogramData() { | ||
this.sendJSONRequestToServer.then(function(responseJson) { |
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.
Bug with scope here since it's not using an arrow function
{ | ||
_.map(this.props.cardiogram.data, (b) => { | ||
const y = this.heartRateToY(b.value); | ||
return <rect |
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.
Good practice to add parentheses for return or you may run into https://github.com/Cardiogram/Cardiogram/pull/4490
* | ||
* TODO(brandon): fix all these darn bugs! | ||
*/ | ||
export default class BuggyHeartRateChart extends React.Component { |
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.
Candidate may point out that we should use a functional component or extend React.PureComponent
since we don't mutate the state/props
return ( | ||
<div | ||
class="chart" | ||
onClick={this.refreshCardiogramData} |
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.
onClick
listeners on div
s require role
for accessability
// 2. What type of object does render() return? What does React do with this object in order to update the DOM? | ||
// 3. Implement heartRateToY() | ||
// 4. How would you extend this to implement pinchToZoom? | ||
// |
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.
Another question to ask is how we can improve the performance of rendering this chart.
- Since all these calculations are done in the render method, we could memoize
timestamp -> x
andheartRate -> y
so that we don't need to recalculate the entire graph on each render
Pull Request Template
Description
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.
Fixes # (issue)
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Test Configuration:
Checklist: