fix: resolve React 19 compatibility by replacing defaultProps with attrs #1351
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes React 19 compatibility issues in Spectacle by replacing all usage of the deprecated
defaultProps
pattern with styled-components'attrs
method.React 19 removed support for
defaultProps
on function components, which was breaking components throughout the Spectacle codebase. While the issue was initially reported for the FullScreen component, investigation revealed that many other components (typography, table, and layout primitives) were also affected.The solution follows the recommended approach from styled-components using the
attrs
method with function variant syntax, which allows props to override defaults while maintaining full backward compatibility.Key Changes:
defaultProps
withstyled.component.attrs((props) => ({ ...defaults, ...props }))
patternFixes #1350
Type of Change
How Has This Been Tested?
Comprehensive Testing Performed:
pnpm run check:ci
- all 26 scripts passpnpm run build
- successful compilationTest Configuration:
Checklist: (Feel free to delete this section upon completion)
pnpm run check:ci
and all checks pass