Skip to content
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ yarn-error.log
.vscode/
/disttest/
/dist/
tsconfig.tsbuildinfo
9 changes: 0 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
"@mux/mux-player-react": "^3.5.1",
"cloudflare-video-element": "^1.3.3",
"dash-video-element": "^0.1.6",
"deepmerge": "^4.0.0",
"hls-video-element": "^1.5.6",
"spotify-audio-element": "^1.0.2",
"tiktok-video-element": "^0.1.0",
Expand Down
21 changes: 10 additions & 11 deletions src/ReactPlayer.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, { lazy, Suspense, useEffect, useState } from 'react';
import merge from 'deepmerge';

import { defaultProps } from './props.js';
import Player from './Player.js';
Expand Down Expand Up @@ -33,8 +32,8 @@ export const createReactPlayer = (players: PlayerEntry[], playerFallback: Player
return null;
};

const ReactPlayer: ReactPlayer = React.forwardRef(({ children, ..._props } , ref) => {
const props = merge(defaultProps, _props);
const ReactPlayer: ReactPlayer = React.forwardRef((_props, ref) => {
const props = { ...defaultProps, ..._props };
Copy link

Copilot AI Jul 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shallow merging props will overwrite nested default objects (e.g., config) instead of merging them. Consider deep merging specific sub-properties like config to preserve nested defaults, for example: config: { ...defaultProps.config, ..._props.config }.

Suggested change
const props = { ...defaultProps, ..._props };
const props = {
...defaultProps,
..._props,
config: { ...defaultProps.config, ..._props.config },
};

Copilot uses AI. Check for mistakes.

const { src, slot, className, style, width, height, fallback, wrapper } = props;
const [showPreview, setShowPreview] = useState(!!props.light);
Expand Down Expand Up @@ -83,19 +82,19 @@ export const createReactPlayer = (players: PlayerEntry[], playerFallback: Player
activePlayer={player.player ?? (player as unknown as PlayerEntry['player'])}
slot={wrapper ? undefined : slot}
className={wrapper ? undefined : className}
style={wrapper
? { display: 'block', width: '100%', height: '100%' }
: { display: 'block', width, height, ...style }}
style={
wrapper
? { display: 'block', width: '100%', height: '100%' }
: { display: 'block', width, height, ...style }
}
config={config}
>{children}</Player>
/>
Copy link

Copilot AI Jul 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The children prop is no longer forwarded to the Player component, which may break nested content rendering. Reintroduce children support by passing {children} into the Player tag or handling it in the wrapper.

Suggested change
/>
>
{children}
</Player>

Copilot uses AI. Check for mistakes.
);
};

const Wrapper: ReactPlayerProps['wrapper'] =
wrapper == null ? ForwardChildren : wrapper;
const Wrapper: ReactPlayerProps['wrapper'] = wrapper == null ? ForwardChildren : wrapper;

const UniversalSuspense =
fallback === false ? ForwardChildren : Suspense;
const UniversalSuspense = fallback === false ? ForwardChildren : Suspense;

return (
<Wrapper slot={slot} className={className} style={{ width, height, ...style }}>
Expand Down
1 change: 0 additions & 1 deletion tsconfig.tsbuildinfo

This file was deleted.