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
fix(react-tooltip): use useIsomorphicLayoutEffect to avoid SSR warnings #17894
Changes from all commits
433d8a9
ecebffc
7953208
e218df2
f9b3307
8faf44f
4fa4d4e
ea782d8
e9393ce
a71b4fd
66760fb
0a16c8e
8974ab0
50a4bf9
4a53719
310e6aa
bfb7f8b
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "patch", | ||
"comment": "ban usage of React.useLayoutEffect as it produces warnings during SSR", | ||
"packageName": "@fluentui/eslint-plugin", | ||
"email": "olfedias@microsoft.com", | ||
"dependentChangeType": "patch" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "none", | ||
"comment": "disable lint for valid usages", | ||
"packageName": "@fluentui/react", | ||
"email": "olfedias@microsoft.com", | ||
"dependentChangeType": "none" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "none", | ||
"comment": "disable lint for valid usages", | ||
"packageName": "@fluentui/react-examples", | ||
"email": "olfedias@microsoft.com", | ||
"dependentChangeType": "none" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "none", | ||
"comment": "disable lint rules", | ||
"packageName": "@fluentui/react-hooks", | ||
"email": "olfedias@microsoft.com", | ||
"dependentChangeType": "none" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "none", | ||
"comment": "disable lint rules", | ||
"packageName": "@fluentui/react-tabs", | ||
"email": "olfedias@microsoft.com", | ||
"dependentChangeType": "none" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "prerelease", | ||
"comment": "use useIsomorphicLayoutEffect to remove a warning during SSR", | ||
"packageName": "@fluentui/react-tooltip", | ||
"email": "olfedias@microsoft.com", | ||
"dependentChangeType": "patch" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "none", | ||
"comment": "disable lint rules", | ||
"packageName": "@fluentui/react-utilities", | ||
"email": "olfedias@microsoft.com", | ||
"dependentChangeType": "none" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,6 +75,7 @@ export const useOverflow = ({ onOverflowItemsChanged, rtl, pinnedIndex }: Overfl | |
return () => containerRef(null); | ||
}); | ||
|
||
// eslint-disable-next-line no-restricted-properties | ||
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. @behowell FYI, might be good to look into whether this could safely be updated to use 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. I'm not familiar enough with SSR to know offhand. Basically this needs to happen at some point--it's ok if it's delayed on the first render after SSR, but it would be bad if it never happened. Is that what 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.
I'm not sure what a good way is to validate SSR. I'm not sure how to manually test it (would have to look that up). For v8 we have an ssr-tests package, but it's limited to extremely basic verification that the components render. 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. Things that are related to DOM calculations/operations probably should never executed on server at all as there is no DOM 🙄 It depends on use case, but sometimes we can simply exclude |
||
React.useLayoutEffect(() => { | ||
const container = containerRef.current; | ||
const menuButton = menuButtonRef.current; | ||
|
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.
Can you also mark this as
@deprecated
? It's not used anywhere and is fundamentally problematic due to useLayoutEffect usage.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.
Sure, marked it by JSDoc & in README.md 👍