Skip to content

Commit e85059d

Browse files
committed
feat!: enable Suspense by default
BREAKING CHANGES: enable Suspense by default, remove environment checks
1 parent 795b196 commit e85059d

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/ReactPlayer.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,7 @@ import { omit, lazy } from './utils'
88
import Player from './Player'
99

1010
const Preview = lazy(() => import(/* webpackChunkName: 'reactPlayerPreview' */'./Preview'))
11-
12-
const IS_BROWSER = typeof window !== 'undefined' && window.document && typeof document !== 'undefined'
13-
const IS_GLOBAL = typeof global !== 'undefined' && global.window && global.window.document
1411
const SUPPORTED_PROPS = Object.keys(propTypes)
15-
16-
// Return null when rendering on the server
17-
// as Suspense is not supported yet
18-
const UniversalSuspense = IS_BROWSER || IS_GLOBAL ? Suspense : () => null
19-
2012
const customPlayers = []
2113

2214
export const createReactPlayer = (players, fallback) => {
@@ -171,6 +163,12 @@ export const createReactPlayer = (players, fallback) => {
171163
const { showPreview } = this.state
172164
const attributes = this.getAttributes(url)
173165
const wrapperRef = typeof Wrapper === 'string' ? this.references.wrapper : undefined
166+
167+
// Many React frameworks like Next.js support Suspense on the server but there are
168+
// others like Fresh that don't plan to support it. Users can disable Suspense
169+
// by setting the fallback prop to false.
170+
const UniversalSuspense = fallback === false ? ({ children }) => children : Suspense
171+
174172
return (
175173
<Wrapper ref={wrapperRef} style={{ ...style, width, height }} {...attributes}>
176174
<UniversalSuspense fallback={fallback}>

0 commit comments

Comments
 (0)