Link follow to notifications in article pages#15558
Conversation
| .catch((error) => { | ||
| window.guardian.modules.sentry.reportError( | ||
| error, | ||
| 'bridget-getTagClient-auto-follow-error', |
There was a problem hiding this comment.
I've assumed it's ok to create a new Sentry error type for this but please let me know if I should just use an existing one e.g. `'bridget-getTagClient-isFollowing-error'
| if (isBridgetCompatible && isMyGuardianEnabled && isNotInBlockList(id)) { | ||
| setShowFollowTagButton(true); | ||
| } | ||
| useEffect(() => { |
There was a problem hiding this comment.
Moved the block list check into a useEffect because the original code was calling setState directly during render
There was a problem hiding this comment.
Why does showFollowTagButton require a useState? It looks like it depends on four properties:
blockList, which is static and never changes.id, which is a prop, and will cause a re-render if changed1.isMyGuardianEnabled, which is a separate state variable, and will cause a re-render if changed2.isBridgetCompatible, which is a separate state variable, and will cause a re-render if changed.
In other words, it looks like it can entirely derived from these, and can therefore just be a value calculated in the body of the component. 1) cannot change, and any changes to 2), 3) or 4) will cause a re-render that will re-calculate this derived value in the body.
Footnotes
|
Hello 👋! When you're ready to run Chromatic, please apply the You will need to reapply the label each time you want to run Chromatic. |
JamieB-gu
left a comment
There was a problem hiding this comment.
Looks good, one question.
| if (isBridgetCompatible && isMyGuardianEnabled && isNotInBlockList(id)) { | ||
| setShowFollowTagButton(true); | ||
| } | ||
| useEffect(() => { |
There was a problem hiding this comment.
Why does showFollowTagButton require a useState? It looks like it depends on four properties:
blockList, which is static and never changes.id, which is a prop, and will cause a re-render if changed1.isMyGuardianEnabled, which is a separate state variable, and will cause a re-render if changed2.isBridgetCompatible, which is a separate state variable, and will cause a re-render if changed.
In other words, it looks like it can entirely derived from these, and can therefore just be a value calculated in the body of the component. 1) cannot change, and any changes to 2), 3) or 4) will cause a re-render that will re-calculate this derived value in the body.
What does this change?
Why?
We are making a stronger link between follow and notifications, by making users follow something before they can set notifications for the subject.
Screenshots