You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The advice "Try change it to ":first-of-type" isn't very sound
The pseudo class ":first-child" is potentially unsafe when doing server-side rendering. Try changing it to ":first-of-type".
Developers would blindly follow this advice to suppress the warning (even outside of SSR)
Props
the advice covers a lot of the use cases
Cons
first-of-type is no substitute for first-child - first-child exists for a reason
you might falsely assume it works as you are working on a specific use case
you might introduce other elements and the first-child is not of the same type
Proposed solution
Update the warning to either exclude the suggestion and make people think of solution that would be best for them, or
replace Try changing it to ":first-of-type" with something like Would ":first-of-type" cover your use case?
Alternative solutions
An easy way (flag/env/config) to disable this warning for the entire project, so that at least non SSR projects can opt out of the warning
Additional context
I've seen people preferring to suppress this warning by using first-of-type instead of an inline comment to avoid code review problems like "Why have you suppressed ... for this statement"
The text was updated successfully, but these errors were encountered:
The problem
The advice "Try change it to ":first-of-type" isn't very sound
Developers would blindly follow this advice to suppress the warning (even outside of SSR)
Props
Cons
first-of-type
is no substitute forfirst-child
-first-child
exists for a reasonProposed solution
Update the warning to either exclude the suggestion and make people think of solution that would be best for them, or
replace
Try changing it to ":first-of-type"
with something likeWould ":first-of-type" cover your use case?
Alternative solutions
An easy way (flag/env/config) to disable this warning for the entire project, so that at least non SSR projects can opt out of the warning
Additional context
I've seen people preferring to suppress this warning by using
first-of-type
instead of an inline comment to avoid code review problems like "Why have you suppressed ... for this statement"The text was updated successfully, but these errors were encountered: