From 9c9431e67e472243e9246c3f3f23de102265e523 Mon Sep 17 00:00:00 2001 From: Oliver Gosling Date: Thu, 3 Nov 2022 10:15:57 +0000 Subject: [PATCH] implement can-autoplay fix for ssr https://github.com/video-dev/can-autoplay/issues/36 --- src/components/TradingLaunch/SoundToggle.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/components/TradingLaunch/SoundToggle.tsx b/src/components/TradingLaunch/SoundToggle.tsx index 2e1a8bc43..6a32b329c 100644 --- a/src/components/TradingLaunch/SoundToggle.tsx +++ b/src/components/TradingLaunch/SoundToggle.tsx @@ -1,5 +1,4 @@ import React, { useState, useEffect } from "react"; -import canAutoPlay from 'can-autoplay'; type Props = { className?: string; @@ -15,11 +14,13 @@ const SoundToggle = ({ className, soundToggle }: Props) => { } useEffect(() => { - canAutoPlay.audio().then((result) => { - if (result.result) { + import('can-autoplay') + .then(module => module.default.audio()) + .then(({ result }) => { + if (result === true) { setSound(true); } - }); + }) }, []); return (