fix suppressHydrationWarning being set to "true" instead of true#5733
Hidden character warning
Conversation
There was a problem hiding this comment.
Greptile Summary
This PR fixes a React hydration issue where the suppressHydrationWarning attribute was incorrectly being set as the string "true" instead of the boolean true. In React/JSX, boolean HTML attributes must be actual boolean values, not string representations.
The changes span three files in the compiler and app modules:
- reflex/app.py: Updates the document root generation to use boolean
Trueinstead of string"true"for thesuppressHydrationWarningattribute - reflex/compiler/compiler.py: Modifies the type annotation for
html_custom_attrsfromdict[str, Var | str]todict[str, Var | Any]and adds theAnyimport - reflex/compiler/utils.py: Updates the matching type annotation in the
create_document_rootfunction
The suppressHydrationWarning prop is a React feature used to suppress hydration mismatch warnings between server-side and client-side rendering. When set incorrectly as a string, React treats it as truthy but semantically incorrect, potentially causing hydration issues. This fix ensures proper React hydration behavior by allowing the type system to accept boolean values while maintaining the existing support for Var objects and other types that may be needed for HTML attributes.
The changes integrate well with Reflex's existing architecture for handling custom HTML attributes and document root compilation, maintaining backward compatibility while fixing the specific boolean attribute issue.
Confidence score: 5/5
- This PR is safe to merge with minimal risk as it fixes a clear type system bug
- Score reflects a straightforward fix addressing a specific React hydration issue with well-defined changes
- No files require special attention as the changes are consistent and well-targeted
3 files reviewed, no comments
CodSpeed Performance ReportMerging #5733 will not alter performanceComparing Summary
|
No description provided.