Skip to content

Commit 60609a7

Browse files
Merge pull request #4498 from shyk001/main
Fix - Removed defaultProps from Function Components for React 18.3.
2 parents 7344120 + 8839334 commit 60609a7

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

src/with_floating.jsx

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,29 @@ export const popperPlacementPositions = [
2525

2626
export default function withFloating(Component) {
2727
const WithFloating = (props) => {
28+
const alt_props = {
29+
...props,
30+
popperModifiers: props.popperModifiers || [],
31+
popperProps: props.popperProps || {},
32+
hidePopper:
33+
typeof props.hidePopper === "boolean" ? props.hidePopper : true,
34+
};
2835
const arrowRef = React.useRef();
2936
const floatingProps = useFloating({
30-
open: !props.hidePopper,
37+
open: !alt_props.hidePopper,
3138
whileElementsMounted: autoUpdate,
32-
placement: props.popperPlacement,
39+
placement: alt_props.popperPlacement,
3340
middleware: [
3441
flip({ padding: 15 }),
3542
offset(10),
3643
arrow({ element: arrowRef }),
37-
...props.popperModifiers,
44+
...alt_props.popperModifiers,
3845
],
39-
...props.popperProps,
46+
...alt_props.popperProps,
4047
});
4148

4249
return (
43-
<Component {...props} popperProps={{ ...floatingProps, arrowRef }} />
50+
<Component {...alt_props} popperProps={{ ...floatingProps, arrowRef }} />
4451
);
4552
};
4653

@@ -51,11 +58,5 @@ export default function withFloating(Component) {
5158
hidePopper: PropTypes.bool,
5259
};
5360

54-
WithFloating.defaultProps = {
55-
popperModifiers: [],
56-
popperProps: {},
57-
hidePopper: true,
58-
};
59-
6061
return WithFloating;
6162
}

0 commit comments

Comments
 (0)