diff --git a/src/components/VolumeController/index.tsx b/src/components/VolumeController/index.tsx index c24801cc..fb55fbed 100644 --- a/src/components/VolumeController/index.tsx +++ b/src/components/VolumeController/index.tsx @@ -1,16 +1,27 @@ -import React, { useState } from 'react' +import React, { useEffect, useState } from 'react' export interface IVolumeController { state: boolean + soundNameOnLocalStorage: string handleSoundVolume: (volume: number) => void } export const VolumeController: React.FC = ({ state, + soundNameOnLocalStorage, handleSoundVolume }) => { const [rangeValue, setRangeValue] = useState(1000) + useEffect(() => { + if (typeof window !== 'undefined') { + const storageValue = localStorage.getItem( + `${soundNameOnLocalStorage}-volume` + ) + if (storageValue) setRangeValue(JSON.parse(storageValue) * 1000) + } + }, []) + return (