Open onurgenes opened 1 month ago
Same problem here... That's the error that I get:
ReferenceError: window is not defined
at It (.../node_modules/react-voice-visualizer/dist/react-voice-visualizer.js:351:106)
Most likely, this component relies on browser-specific context, so it won't work with SSR frameworks like Remix or Nest.Js. I have tried to wrap this component into something like this:
const ClientOnly = ({ children }: { children: React.ReactNode }) => {
const [isMounted, setIsMounted] = useState(false);
useEffect(() => {
setIsMounted(true);
}, []);
return isMounted ? children : null;
};
But still, it doesn't seem to be functioning properly, although it renders, which is kind of a win.
UPD: I found a way to make it work!
const [isMounted, setIsMounted] = useState(false);
useEffect(() => {
setIsMounted(true);
}, []);
// in your render...
{isMounted && (
<VoiceVisualizer
controls={recorderControls}
/>
)}
That will ensure that your window context is accessible.
Visualization is not working while recording on NextJS. I have tried with the example from this repo 👉🏻 https://github.com/YZarytskyi/react-audio-visualization
To Reproduce Steps to reproduce the behavior:
Expected behavior It should be working as given demo of the library.