8000 WRQ-19328: Fix React 18.3 warnings in enact by juwonjeong · Pull Request #3238 · enactjs/enact · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

WRQ-19328: Fix React 18.3 warnings in enact #3238

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
"invariant": "^2.2.4",
"prop-types": "^15.8.1",
"ramda": "^0.29.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-is": "^18.2.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-is": "^18.3.1",
"warning": "^4.0.3"
}
}
4 changes: 2 additions & 2 deletions packages/i18n/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
"@enact/core": "^4.9.0-alpha.1",
"prop-types": "^15.8.1",
"ramda": "^0.29.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"xhr": "^2.6.0"
},
"peerDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/sampler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"classnames": "^2.5.1",
"ilib": "14.19.0",
"prop-types": "^15.8.1",
"react": "^18.2.0",
"react-dom": "^18.2.0"
"react": "^18.3.1",
"react-dom": "^18.3.1"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ const SpotlightContainerDecorator = hoc(defaultConfig, (config, Wrapped) => {

// eslint-disable-next-line no-shadow
function SpotlightContainerDecorator (props) {
const {spotlightDisabled, spotlightId, spotlightMuted, spotlightRestrict, ...rest} = props;
const {spotlightDisabled = false, spotlightId, spotlightMuted = false, spotlightRestrict = 'self-first', ...rest} = props;

const spotlightContainer = useSpotlightContainer({
id: spotlightId,
Expand Down Expand Up @@ -250,12 +250,6 @@ const SpotlightContainerDecorator = hoc(defaultConfig, (config, Wrapped) => {
spotlightRestrict: PropTypes.oneOf(['none', 'self-first', 'self-only'])
};

SpotlightContainerDecorator.defaultProps = {
spotlightDisabled: false,
spotlightMuted: false,
spotlightRestrict: 'self-first'
};

// Wrapping with a React.Component to maintain ref support
return class SpotlightContainerDecoratorAdapter extends Component {
render () {
Expand Down
4 changes: 2 additions & 2 deletions packages/spotlight/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
"classnames": "^2.5.1",
"prop-types": "^15.8.1",
"ramda": "^0.29.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"warning": "^4.0.3"
}
}
3 changes: 2 additions & 1 deletion packages/ui/Repeater/Repeater.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ const RepeaterBase = kind({
}
if (indexProp) props[indexProp] = index;

return <Component {...props} />;
const {key, ...rest} = {...props};
return <Component key={key} {...rest} />;
});
}
},
Expand Down
40 changes: 22 additions & 18 deletions packages/ui/Scroller/Scroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,24 @@ import ScrollerBase from './UiScrollerBase';

const nop = () => {};

const scrollerDefaultProps = {
cbScrollTo: nop,
direction: 'both',
horizontalScrollbar: 'auto',
noScrollByDrag: false,
noScrollByWheel: false,
onScroll: nop,
onScrollStart: nop,
onScrollStop: nop,
overscrollEffectOn: {
drag: false,
pageKey: false,
wheel: false
},
scrollMode: 'translate',
verticalScrollbar: 'auto'
};

/**
* An unstyled scroller.
*
Expand All @@ -35,6 +53,8 @@ const nop = () => {};
const Scroller = (props) => {
// Hooks

const scrollerProps = Object.assign({}, scrollerDefaultProps, props);

const {
scrollContentHandle,
scrollContentWrapper: ScrollContentWrapper,
Expand All @@ -48,7 +68,7 @@ const Scroller = (props) => {
scrollContentProps,
verticalScrollbarProps,
horizontalScrollbarProps
} = useScroll(props);
} = useScroll(scrollerProps);

// Return

Expand Down Expand Up @@ -257,23 +277,7 @@ Scroller.propTypes = /** @lends ui/Scroller.Scroller.prototype */ {
verticalScrollbar: PropTypes.oneOf(['auto', 'visible', 'hidden'])
};

Scroller.defaultProps = {
cbScrollTo: nop,
direction: 'both',
horizontalScrollbar: 'auto',
noScrollByDrag: false,
noScrollByWheel: false,
onScroll: nop,
onScrollStart: nop,
onScrollStop: nop,
overscrollEffectOn: {
drag: false,
pageKey: false,
wheel: false
},
scrollMode: 'translate',
verticalScrollbar: 'auto'
};
Scroller.defaultPropValues = scrollerDefaultProps;

export default Scroller;
export {
Expand Down
6 changes: 1 addition & 5 deletions packages/ui/Slottable/tests/Slottable-specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,18 +240,14 @@ describe('Slottable Specs', () => {
});

test('should allow downstream component to have default value for unset slot', () => {
function ComponentBase ({a}) {
function ComponentBase ({a = 'Default A'}) {
return (
<div data-testid="slottable">
{a}
</div>
);
}

ComponentBase.defaultProps = {
a: 'Default A'
};

const Component = Slottable({slots: ['a']}, ComponentBase);

render(<Component />);
Expand Down
9 changes: 3 additions & 6 deletions packages/ui/Toggleable/Toggleable.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,14 @@ const ToggleableHOC = hoc(defaultConfig, (config, Wrapped) => {
)
};

function Toggleable (props) {
function Toggleable ({disabled = false, ...rest}) {
const props = {disabled, ...rest};
const updated = {...props};
const propSelected = props[prop];

const hook = useToggle({
defaultSelected: props[defaultPropKey],
disabled: props.disabled,
disabled,
onToggle: (ev) => forwardCustom(toggle, adapter)(ev, props),
prop,

Expand Down Expand Up @@ -253,10 +254,6 @@ const ToggleableHOC = hoc(defaultConfig, (config, Wrapped) => {
[toggle]: PropTypes.func
};

Toggleable.defaultProps = {
disabled: false
};

return Toggleable;
});

Expand Down
8 changes: 2 additions & 6 deletions packages/ui/Touchable/Touchable.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ const Touchable = hoc(defaultConfig, (config, Wrapped) => {

// eslint-disable-next-line no-shadow
const Touchable = forwardRef((props, ref) => {
const {configForHook, propsForWrapped} = selectProps(props);
const {disabled = false, noResume = false, ...rest} = props;
const {configForHook, propsForWrapped} = selectProps({disabled, noResume, ...rest});
const hook = useTouch({getActive: !!activeProp, ...configForHook});

Object.assign(propsForWrapped, hook.handlers);
Expand Down Expand Up @@ -369,11 +370,6 @@ const Touchable = hoc(defaultConfig, (config, Wrapped) => {
pinchConfig: pinchConfigPropType
};

Touchable.defaultProps = {
disabled: false,
noResume: false
};

Touchable.displayName = 'Touchable';

return Touchable;
Expand Down
50 changes: 29 additions & 21 deletions packages/ui/VirtualList/VirtualList.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,25 @@ import {gridListItemSizeShape, itemSizesShape, VirtualListBasic} from './Virtual

const nop = () => {};

const virtualListDefaultProps = {
cbScrollTo: nop,
direction: 'vertical',
horizontalScrollbar: 'auto',
noScrollByDrag: false,
noScrollByWheel: false,
onScroll: nop,
onScrollStart: nop,
onScrollStop: nop,
overscrollEffectOn: {
drag: false,
pageKey: false,
wheel: false
},
role: 'list',
scrollMode: 'translate',
verticalScrollbar: 'auto'
};

/**
* An unstyled scrollable virtual list component with touch support.
*
Expand All @@ -33,6 +52,8 @@ const nop = () => {};
const VirtualList = (props) => {
// Hooks

const virtualListProps = Object.assign({}, virtualListDefaultProps, props);

const {
scrollContentHandle,
scrollContentWrapper: ScrollContentWrapper,
Expand All @@ -46,7 +67,7 @@ const VirtualList = (props) => {
scrollContentProps,
verticalScrollbarProps,
horizontalScrollbarProps
} = useScroll(props);
} = useScroll(virtualListProps);

// Render

Expand Down Expand Up @@ -276,7 +297,9 @@ VirtualList.propTypes = /** @lends ui/VirtualList.VirtualList.prototype */ {
verticalScrollbar: PropTypes.oneOf(['auto', 'visible', 'hidden'])
};

VirtualList.defaultProps = {
VirtualList.defaultPropValues = virtualListDefaultProps;

const virtualGridListDefaultProps = {
cbScrollTo: nop,
direction: 'vertical',
horizontalScrollbar: 'auto',
Expand Down Expand Up @@ -305,6 +328,8 @@ VirtualList.defaultProps = {
* @public
*/
const VirtualGridList = (props) => {
const virtualGridListProps = Object.assign({}, virtualGridListDefaultProps, props);

const {
scrollContentHandle,
scrollContentWrapper: ScrollContentWrapper,
Expand All @@ -318,7 +343,7 @@ const VirtualGridList = (props) => {
scrollContentProps,
verticalScrollbarProps,
horizontalScrollbarProps
} = useScroll(props);
} = useScroll(virtualGridListProps);

return (
<ResizeContext.Provider {...resizeContextProps}>
Expand Down Expand Up @@ -546,24 +571,7 @@ VirtualGridList.propTypes = /** @lends ui/VirtualList.VirtualGridList.prototype
verticalScrollbar: PropTypes.oneOf(['auto', 'visible', 'hidden'])
};

VirtualGridList.defaultProps = {
cbScrollTo: nop,
direction: 'vertical',
horizontalScrollbar: 'auto',
noScrollByDrag: false,
noScrollByWheel: false,
onScroll: nop,
onScrollStart: nop,
onScrollStop: nop,
overscrollEffectOn: {
drag: false,
pageKey: false,
wheel: false
},
role: 'list',
scrollMode: 'translate',
verticalScrollbar: 'auto'
};
VirtualGridList.defaultPropValues = virtualGridListDefaultProps;

export default VirtualList;
export {
Expand Down
6 changes: 3 additions & 3 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
"invariant": "^2.2.4",
"prop-types": "^15.8.1",
"ramda": "^0.29.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-is": "^18.2.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-is": "^18.3.1",
"warning": "^4.0.3"
}
}
10 changes: 2 additions & 8 deletions packages/ui/useScroll/Scrollbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ const useScrollbar = (props) => {
* @ui
* @private
*/
const Scrollbar = memo((props) => {
const Scrollbar = memo(({corner = false, css = componentCss, minThumbSize = 18, vertical = true, ...rest}) => {
const props = {corner, css, minThumbSize, vertical, ...rest};
const {
restProps,
scrollbarProps,
Expand Down Expand Up @@ -197,13 +198,6 @@ Scrollbar.propTypes = /** @lends ui/useScroll.Scrollbar.prototype */ {
vertical: PropTypes.bool
};

Scrollbar.defaultProps = {
corner: false,
css: componentCss,
minThumbSize: 18,
vertical: true
};

export default Scrollbar;
export {
Scrollbar,
Expand Down
6 changes: 1 addition & 5 deletions packages/ui/useScroll/ScrollbarTrack.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import css from './ScrollbarTrack.module.less';
*/
const ScrollbarTrack = forwardRef((props, ref) => {
const
{vertical, ...rest} = props,
{vertical = true, ...rest} = props,
className = classNames(css.scrollbarTrack, vertical ? css.vertical : null);

return <div {...rest} className={className} ref={ref} />;
Expand All @@ -31,10 +31,6 @@ ScrollbarTrack.propTypes = /** @lends ui/useScroll.ScrollbarTrack.prototype */ {
vertical: PropTypes.bool
};

ScrollbarTrack.defaultProps = {
vertical: true
};

const MemoizedScrollbarTrack = memo(ScrollbarTrack);

MemoizedScrollbarTrack.displayName = 'ui:ScrollbarTrack';
Expand Down
4 changes: 2 additions & 2 deletions packages/webos/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"dependencies": {
"@enact/core": "^4.9.0-alpha.1",
"prop-types": "^15.8.1",
"react": "^18.2.0",
"react-dom": "^18.2.0"
"react": "^18.3.1",
"react-dom": "^18.3.1"
}
}
Loading
0