-
-
Notifications
You must be signed in to change notification settings - Fork 39
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
No questions remaining UI #56
Changes from all commits
cef4de6
357b084
63fed89
3dafa43
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,15 @@ export default function Questions() { | |
useQuestionBuffer(filterState); | ||
const question = buffer[0] ?? null; | ||
|
||
const resetFilters = React.useCallback( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. useCallback (memoization) may not be needed in this case, maybe go with a normal arrow function? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The It's not entirely useless, because There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I guess that the baseline is if the useCallback memoization improves performance. I think that in this case as the QuestionDisplay is a presentational component and doesn't have heavy computations or something really slow, there is not a lot of benefit in memoizing the reset function and makes the code a bit more complex. Also, the memoization is not cost free, it will store in memory and every render needs to compare with dependency array. Besides that, the QuestionDisplay will rerender every time the Questions (index) rerenders, unless QuestionDisplay itself is memoized. |
||
() => | ||
setFilterState((prevState) => ({ | ||
insightType: prevState.insightType, | ||
sortByPopularity: prevState.sortByPopularity, | ||
})), | ||
[setFilterState] | ||
); | ||
|
||
return ( | ||
<Grid container spacing={2} p={2}> | ||
<Grid item sm={12} md={5}> | ||
|
@@ -30,6 +39,7 @@ export default function Questions() { | |
<QuestionDisplay | ||
question={question} | ||
answerQuestion={answerQuestion} | ||
resetFilters={resetFilters} | ||
/> | ||
</Stack> | ||
</Grid> | ||
|
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.
<h1>
has a meaning: this is the top title of the page. I assume the top title of this page is not "OR" 😉Same for
h2
,h3
, ... If you want a big text use CSS, not HTMLOn this topic, you can read
<Typography/>
docThis components hase two important props:
variant
: defines how the text will look like (here it will look like a top title)component
the HML compont which will be used (the sementic meaning (here it's a basic text)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.
Oh okay, got it. Thank you. I'll make the changes