fix: convert icon components from class to functional to resolve defaultProps deprecation (#2912)#3325
Open
pierreeurope wants to merge 2 commits intokeplergl:masterfrom
Open
Conversation
…ultProps deprecation (keplergl#2912) Convert Base icon component and all 17 layer/cloud-provider icon components from class components with static defaultProps to functional components with JavaScript default parameters. This resolves the React deprecation warning: 'Support for defaultProps will be removed from function components'. - Replace null defaults with undefined for SVG attribute compatibility - Remove 'size' prop from layer icons (not part of BaseProps) Fixes keplergl#2912 Signed-off-by: pierreeurope <pierre.europe@pm.me>
4e88555 to
3adf049
Compare
Signed-off-by: pierreeurope <pierre.europe@pm.me>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Partially addresses #2912 — Eliminates React deprecation warnings for
defaultPropson icon components.Problem
React 18.3+ warns about
defaultPropsusage, which will be removed in a future major release. TheBaseicon component and all layer icon components used class components withstatic defaultProps, generating console warnings.Solution
Converted all icon components from class components to functional components using JavaScript default parameters instead of
static defaultProps:src/layers/src/base.tsx— CoreBaseSVG icon componentsrc/cloud-providers/src/base.tsx— Duplicate Base component for cloud providerssrc/cloud-providers/src/upload.tsx— Upload iconsrc/layers/src/table.tsx— Table iconAlso removed unused
PropTypesimports since functional components don't use them.Impact
Baseis still exported with the same name and props