-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
chore(website): Enable react-hooks exhaustive deps rules #5663
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
Changes from all commits
6250d99
0c70dca
1e4239a
9996cd3
59b66ac
c025a31
507c7a5
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 |
---|---|---|
|
@@ -84,6 +84,15 @@ function Playground(): JSX.Element { | |
[setState], | ||
); | ||
|
||
const onLoaded = useCallback( | ||
(ruleNames: RuleDetails[], tsVersions: readonly string[]): void => { | ||
setRuleNames(ruleNames); | ||
setTSVersion(tsVersions); | ||
setIsLoading(false); | ||
}, | ||
[], | ||
); | ||
|
||
Comment on lines
+87
to
+95
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. This small refactoring was necessary to fix an issue raised by updating one of the dependency arrays on useSandboxServices.ts: Since the original |
||
return ( | ||
<div className={styles.codeContainer}> | ||
{ruleNames.length > 0 && ( | ||
|
@@ -150,11 +159,7 @@ function Playground(): JSX.Element { | |
onMarkersChange={setMarkers} | ||
decoration={selectedRange} | ||
onChange={setState} | ||
onLoaded={(ruleNames, tsVersions): void => { | ||
setRuleNames(ruleNames); | ||
setTSVersion(tsVersions); | ||
setIsLoading(false); | ||
}} | ||
onLoaded={onLoaded} | ||
onSelect={setPosition} | ||
/> | ||
</div> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,21 +11,23 @@ export interface PropertyNameProps { | |
} | ||
|
||
export default function PropertyName(props: PropertyNameProps): JSX.Element { | ||
const { onClick: onClickProps, onHover } = props; | ||
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. Destructuring props to avoid stale values as suggested by: facebook/react#16265 (comment) |
||
|
||
const onClick = useCallback( | ||
(e: MouseEvent<HTMLElement>) => { | ||
e.preventDefault(); | ||
props.onClick?.(e); | ||
onClickProps?.(e); | ||
}, | ||
[props.onClick], | ||
[onClickProps], | ||
); | ||
|
||
const onMouseEnter = useCallback(() => { | ||
props.onHover?.(true); | ||
}, [props.onHover]); | ||
onHover?.(true); | ||
}, [onHover]); | ||
|
||
const onMouseLeave = useCallback(() => { | ||
props.onHover?.(false); | ||
}, [props.onHover]); | ||
onHover?.(false); | ||
}, [onHover]); | ||
|
||
return props.onClick || props.onHover ? ( | ||
<> | ||
|
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.
Sets the rules to the default behaviour ("warn").