Skip to content

Commit

Permalink
STCOM-1291 avoid defaultProps in functional components (#1469)
Browse files Browse the repository at this point in the history
`defaultProps` for functional components will be deprecated in React v19
in favor of ES6 default parameters.

Refs STCOR-844
  • Loading branch information
zburke authored May 22, 2024
1 parent 142ff27 commit 05badf9
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 24 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* Make branding optional. Refs STCOR-847.
* Idle-session timeout and "Keep working?" modal. Refs STCOR-776.
* Implement password validation for Login Page. Refs STCOR-741.
* Avoid deprecated `defaultProps` for functional components. Refs STCOR-844..

## [10.1.0](https://github.com/folio-org/stripes-core/tree/v10.1.0) (2024-03-12)
[Full Changelog](https://github.com/folio-org/stripes-core/compare/v10.0.0...v10.1.0)
Expand Down
18 changes: 5 additions & 13 deletions src/components/AppIcon/AppIcon.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ import { withStripes } from '../../StripesContext';
import css from './AppIcon.css';

const AppIcon = ({
iconAlignment,
iconAriaHidden,
size,
iconAlignment = 'center',
iconAriaHidden = true,
size = 'medium',
icon,
alt,
src,
style,
children,
className,
tag,
tag = 'span',
app,
iconKey,
iconKey = 'app',
iconClassName,
stripes,
}) => {
Expand Down Expand Up @@ -137,12 +137,4 @@ AppIcon.propTypes = {
tag: PropTypes.string,
};

AppIcon.defaultProps = {
iconAlignment: 'center',
iconAriaHidden: true,
iconKey: 'app',
size: 'medium',
tag: 'span',
};

export default withStripes(AppIcon);
7 changes: 1 addition & 6 deletions src/components/MainNav/NavButton/NavButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ const propTypes = {
to: PropTypes.string,
};

const defaultProps = {
noSelectedBar: false,
};

const NavButton = React.forwardRef(({
ariaLabel,
badge,
Expand All @@ -50,7 +46,7 @@ const NavButton = React.forwardRef(({
innerClassName,
label,
labelClassName,
noSelectedBar,
noSelectedBar = false,
onClick,
open,
selected,
Expand Down Expand Up @@ -137,6 +133,5 @@ const NavButton = React.forwardRef(({
});

NavButton.propTypes = propTypes;
NavButton.defaultProps = defaultProps;

export default NavButton;
6 changes: 1 addition & 5 deletions src/components/RouteErrorBoundary/RouteErrorBoundary.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { getEventHandlers } from '../../handlerService';
import { ModulesContext } from '../../ModulesContext';
import { StripesContext } from '../../StripesContext';

const RouteErrorBoundary = ({ children, escapeRoute, moduleName, isSettings }) => {
const RouteErrorBoundary = ({ children, escapeRoute = '/', moduleName, isSettings }) => {
const intl = useIntl();
let buttonLabelId;

Expand Down Expand Up @@ -64,8 +64,4 @@ RouteErrorBoundary.propTypes = {
isSettings: PropTypes.bool,
};

RouteErrorBoundary.defaultProps = {
escapeRoute: '/'
};

export default RouteErrorBoundary;

0 comments on commit 05badf9

Please sign in to comment.