-
Notifications
You must be signed in to change notification settings - Fork 42
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
[Linting] Fixed useExhaustiveDependencies in biome #3197
Conversation
🦋 Changeset detectedLatest commit: 3abd5e8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 7 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
const isLimitReached = useMemo(() => { | ||
return ( | ||
(!!maxSelected?.limit && selectedOptions.length >= maxSelected.limit) || | ||
(!isMultiSelect && selectedOptions.length > 0) | ||
); | ||
}, [maxSelected, selectedOptions, isMultiSelect]); |
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.
Since there's no expensive calculations here, I don't think useMemo
will have any benefits in this case.
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.
Its memozied to avoid this useEffect from running all the time:
useEffect(() => {
setHideCaret(isLimitReached);
}, [isLimitReached, setHideCaret]);
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.
Since isLimitReached
is a boolean, it will not change on each render, as opposed to an object.
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.
🧠 🧠 🧠 🧠 🧠 🧠 🧠 TIL! So used to using bools in states like const [flag, setFlag]= useState..
where changing flag
to the same value will cause useEffect from running that i didn't even know this
@navikt/core/react/src/form/combobox/SelectedOptions/selectedOptionsContext.tsx
Outdated
Show resolved
Hide resolved
@navikt/core/react/src/overlays/dismissablelayer/DismissableLayer.tsx
Outdated
Show resolved
Hide resolved
…yer.tsx Co-authored-by: Halvor Haugan <[email protected]>
Storybook demo6637a2a3a | 90 komponenter | 141 stories |
Description
Some were still relevant, but most could be updated/refactored
As for the
iFrame
change in sanity, instead of resolving the useEffect we now usesanity-plugin-iframe-pane
(https://www.sanity.io/plugins/iframe-pane) that solves this for us. All we need to do is provide it an URL like we already did. Will need to test this in dev to make sure it still works as intendedPerformance Optimizations:
.changeset/bright-meals-repair.md
).Refactoring and Cleanup:
useEffect
hooks in multiple files:@navikt/aksel-icons/figma-plugin/src/ui/App.tsx
@navikt/core/react/src/form/combobox/Input/Input.context.tsx
@navikt/core/react/src/form/combobox/SelectedOptions/selectedOptionsContext.tsx
@navikt/core/react/src/form/combobox/customOptionsContext.tsx
@navikt/core/react/src/modal/Modal.tsx
@navikt/core/react/src/overlays/dismissablelayer/DismissableLayer.tsx
@navikt/core/react/src/progress-bar/ProgressBar.tsx
@navikt/core/react/src/table/AnimateHeight.tsx
@navikt/core/react/src/util/TextareaAutoSize.tsx
@navikt/core/react/src/util/create-context.tsx
@navikt/core/react/src/util/hooks/descendants/descendant.stories.tsx
Component Checklist 📝
@navikt/core/css/config/_mappings.js
)@navikt/core/css/tokens.json
)@navikt/aksel-stylelint/src/deprecations.ts
)@navikt/core/react/src/index.ts
and@navikt/core/react/package.json
)@navikt/core/css/index.css
)<Component>: <gitmoji?> <Text>.
E.g. "Button: ✨ Add feature xyz.")