Repository navigation
refactor: [M3-6708] – Implement new React 18 hooks - #10261
Merged
dwiley-akamai merged 5 commits intoMar 12, 2024
Merged
Conversation
dwiley-akamai
commented
Mar 7, 2024
Comment on lines
-18
to
-20
| - When conditionally rendering JSX, use ternaries instead of `&&`. | ||
| - Example: `condition ? <Component /> : null` instead of `condition && <Component />` | ||
| - This is to avoid hard-to-catch bugs ([read more](https://kentcdodds.com/blog/use-ternaries-rather-than-and-and-in-jsx)). |
Contributor
Author
There was a problem hiding this comment.
We moved away from this convention about a year ago, but this was lingering in our Coding Standards.
dwiley-akamai
marked this pull request as ready for review
March 7, 2024 20:36
dwiley-akamai
requested review from
abailly-akamai and
hana-akamai
and removed request for
a team
March 7, 2024 20:36
dwiley-akamai
commented
Mar 7, 2024
| - When conditionally rendering JSX, use ternaries instead of `&&`. | ||
| - Example: `condition ? <Component /> : null` instead of `condition && <Component />` | ||
| - This is to avoid hard-to-catch bugs ([read more](https://kentcdodds.com/blog/use-ternaries-rather-than-and-and-in-jsx)). | ||
| [Several new hooks were introduced with the release of React 18](https://react.dev/blog/2022/03/29/react-v18#new-hooks). |
Contributor
Author
There was a problem hiding this comment.
If/when other newly-introduced hooks get used in the code base, perhaps guidelines/explanations around their usage could be included in this section also.
abailly-akamai
approved these changes
Mar 11, 2024
abailly-akamai
left a comment
Contributor
There was a problem hiding this comment.
This makes sense, and achieves the intended result - ✅
thanks for updating the documentation!
hana-akamai
approved these changes
Mar 12, 2024
This was referenced Mar 18, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description 📝
With our recent upgrade to React 18, we can begin making use of new hooks that were introduced with that version. This PR implements
useId()in a few files.useTransitionmostly superfluous to us.componentDidMountandcomponentWillUnmount, so it may have some applicability when converting class components to function components.Changes 🔄
useId()inGroupByTagToggle.tsx,LinodeConfigDialog.tsx,DisplayGroupedLinodes.tsx,DisplayLinodes.tsx, andSortableTableHead.tsxHow to test 🧪
Verification steps
With VoiceOver on, ensure there have been no regressions/changes compared to prod for the following:
Alternatively or in addition to the above, you can verify by looking at the HTML and confirming that the
idandaria-describedbyattributes on the related elements match up:As an Author I have considered 🤔