Skip to content

Commit

Permalink
implement can-autoplay fix for ssr video-dev/can-autoplay#36
Browse files Browse the repository at this point in the history
  • Loading branch information
goslingo committed Nov 3, 2022
1 parent df19473 commit 9c9431e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/components/TradingLaunch/SoundToggle.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, { useState, useEffect } from "react";
import canAutoPlay from 'can-autoplay';

type Props = {
className?: string;
Expand All @@ -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 (
Expand Down

0 comments on commit 9c9431e

Please sign in to comment.