-
Notifications
You must be signed in to change notification settings - Fork 131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ReferenceError: Worker is not defined #107
Comments
Any solution? |
Error also exists on my end. Here's package.json dependencies. I'm using Nextjs with React 18
|
try this in nextjs: const ReactMediaRecorder = dynamic(() => import('react-media-recorder').then((mod) => mod.ReactMediaRecorder), {
ssr: false,
}); |
ReferenceError: dynamic is not defined |
need to import dynamic from "next/dynamic".
|
then how we can import this useReactMediaRecorder hook if we get the same error |
Here is my solution for hooks related to useReactMediaRecorder or class-base too: Assume we have a custom component called CustomMediaRecorder that uses useReactMediaRecorder. We want to use this component in the current component.
NB. CustomMediaRecorder can be a class-based or functional component. Import it into your current component like the code snippet above shows. |
what is the solution for Remix based projects? |
@rorlich since the workaround seems to exclude the part from rendering on server side, you can use the client side rendering of Remix. See here https://remix.run/resources/remix-utils#clientonly |
got it, thanks
…On Tue, Jan 30, 2024 at 2:39 PM iwan933 ***@***.***> wrote:
@rorlich <https://github.com/rorlich> since the workaround seems to
exclude the part from rendering on server side, you can use the client side
rendering of Remix. See here
https://remix.run/resources/remix-utils#clientonly
—
Reply to this email directly, view it on GitHub
<#107 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABEGVOYWSNN2XQ2JMCFUEX3YRDSY5AVCNFSM552PJ6LKU5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOJRGY3TKNZXHA3A>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
How do we get the hook? useMediaRecorder? I am trying to do it with below code to set the state. But it never works. Any suggestions?
|
I solve this problem by dynamic import the component A containing
|
add top of the component. |
That did the trick for me...😃 |
Does anyone has this working in NextJS and has an example of it? I'm getting an |
same error with nextjs |
I am using NextJS 14.1.1. What I did was created a separate component for AudioRecording named Imported this component dynamically import dynamic from "next/dynamic";
const AudioRecorder = dynamic(() => import("./AudioRecorder"), { ssr: false }); And used it like <AudioRecorder
onRecordingComplete={(file) =>
// my state update
}
isRecording={false}
/> and I got it to work without giving build time errors |
Hi, I have recently tried to use this package in react 18, but I got an error called "Worker is not defined".
Here is the package.json:
[...] "dependencies": { "next": "12.2.3", "react": "18.2.0", "react-dom": "18.2.0", "react-icons": "^4.4.0", "react-media-recorder": "^1.6.6" }, "devDependencies": { "@types/node": "18.6.3", "@types/react": "18.0.15", "@types/react-dom": "18.0.6", "eslint": "8.21.0", "eslint-config-next": "12.2.3", "typescript": "4.7.4" } }
And the element I put the record in is:
The text was updated successfully, but these errors were encountered: