Skip to content

Commit

Permalink
refactor(React): initialize default props with serially stable values (
Browse files Browse the repository at this point in the history
…#14720)

* refactor(React): initialize default props with serially stable values

* refactor(React): fix more components

* test(React): update snapshots

* refactor(React): remove mroe default props

* fix(React): adjust tests to use required props

* chore(Storybook): fix console warnings by adding required props

* refactor(React): remove more default props

* chore(test): update snapshots

* refactor(React): remove more default props, some required props

* refactor(React): initialize default props with serially stable values

* refactor(React): fix more components

* test(React): update snapshots

* refactor(React): remove mroe default props

* fix(React): adjust tests to use required props

* chore(Storybook): fix console warnings by adding required props

* refactor(React): remove more default props

* chore(test): update snapshots

* refactor(React): remove more default props, some required props

* refactor(React): remove more defaultProps from components

* chore(snapshots): update snapshots

* refactor(DataTable): remove default props

* chore(test): update snapshots

* fix(React): clean up a few more components

* fix(Slider): remove defaultProps from Slider
  • Loading branch information
tw15egan authored Oct 19, 2023
1 parent f593b3f commit 2ebd2cb
Show file tree
Hide file tree
Showing 81 changed files with 549 additions and 1,295 deletions.
21 changes: 16 additions & 5 deletions packages/icon-build-helpers/src/builders/react/components/Icon.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,14 @@ import PropTypes from 'prop-types';
import React from 'react';

const Icon = React.forwardRef(function Icon(
{ className, children, tabIndex, ...rest },
{
className,
children,
tabIndex,
xmlns = 'http://www.w3.org/2000/svg',
preserveAspectRatio = 'xMidYMid meet',
...rest
},
ref
) {
const { tabindex, ...props } = getAttributes({
Expand All @@ -29,6 +36,14 @@ const Icon = React.forwardRef(function Icon(
props.ref = ref;
}

if (xmlns) {
props.xmlns = xmlns;
}

if (preserveAspectRatio) {
props.preserveAspectRatio = preserveAspectRatio;
}

return React.createElement('svg', props, children);
});

Expand All @@ -46,9 +61,5 @@ Icon.propTypes = {
width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
xmlns: PropTypes.string,
};
Icon.defaultProps = {
xmlns: 'http://www.w3.org/2000/svg',
preserveAspectRatio: 'xMidYMid meet',
};

export default Icon;
Loading

0 comments on commit 2ebd2cb

Please sign in to comment.