You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Type '() => JSX.Element' is not assignable to type '((string | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal | null) & ((childrenProps: ChildrenProps) => Element)) | undefined'.
Type '() => JSX.Element' is not assignable to type 'string & ((childrenProps: ChildrenProps) => Element)'.
Type '() => JSX.Element' is not assignable to type 'string'.
What can be the best way to remove this error?
Just passing the Element doesn't help. I am using React 18.3.1 and seems like the error is because in React 18, the children prop now needs to be listed explicitly when defining props; or something on those lines.
Please help!
The text was updated successfully, but these errors were encountered:
importWebcamfrom'react-webcam'import{useCallback,useRef}from'react'constvideoConstraints={width: 400,height: 400}exportdefaultfunctionAvatarInput(){constwebcamRef=useRef<Webcam>(null)// Call this function to take a screenshotconstcapture=useCallback(()=>{constimageSrc=webcamRef.current?.getScreenshot()returnimageSrc},[webcamRef])return(<Webcamref={webcamRef}height={400}width={400}screenshotFormat="image/jpeg"videoConstraints={videoConstraints}mirrored/>)}
Edit: I see you were already using a ref, so there is no need to add children in the Webcam component. Just use the ref to capture just like the guide and my sample code.
Please follow the general troubleshooting steps first:
Bug reports:
CodeSandbox: https://codesandbox.io/p/sandbox/v2gpf8
Type Error:
What can be the best way to remove this error?
Just passing the Element doesn't help. I am using React 18.3.1 and seems like the error is because in React 18, the children prop now needs to be listed explicitly when defining props; or something on those lines.
Please help!
The text was updated successfully, but these errors were encountered: