Skip to content

Commit

Permalink
Remove defaultProps from React package
Browse files Browse the repository at this point in the history
React 18.3 added a deprecation warning for usage of defaultProps in functional components.
  • Loading branch information
lborba committed May 4, 2024
1 parent 805e1f8 commit c6bd549
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 12 deletions.
6 changes: 1 addition & 5 deletions packages/react/src/components/LanguagePicker.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import useTX from '../hooks/useTX';
*
* - className: the CSS class to use on the <select> tag */

export default function LanguagePicker({ className }) {
export default function LanguagePicker({ className = '' }) {
const languages = useLanguages();
const locale = useLocale();
const tx = useTX();
Expand All @@ -31,7 +31,3 @@ export default function LanguagePicker({ className }) {
LanguagePicker.propTypes = {
className: PropTypes.string,
};

LanguagePicker.defaultProps = {
className: '',
};
2 changes: 0 additions & 2 deletions packages/react/src/components/T.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,4 @@ export default function T({ _str, ...props }) {
return useT()(_str, props);
}

T.defaultProps = {};

T.propTypes = { _str: PropTypes.string.isRequired };
6 changes: 1 addition & 5 deletions packages/react/src/components/UT.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import useT from '../hooks/useT';
* `div` or a `span`.
* */

export default function UT({ _str, _inline, ...props }) {
export default function UT({ _str, _inline = false, ...props }) {
const translation = useT()(
_str,
{ _inline, _escapeVars: true, ...props },
Expand All @@ -28,10 +28,6 @@ export default function UT({ _str, _inline, ...props }) {
return React.createElement(parent, parentProps);
}

UT.defaultProps = {
_inline: false,
};

UT.propTypes = {
_str: PropTypes.string.isRequired,
_inline: PropTypes.bool,
Expand Down

0 comments on commit c6bd549

Please sign in to comment.