React-Dropzone - Error: Invalid hook call
See original GitHub issueDo you want to request a feature or report a bug?
- I found a bug
- I want to propose a feature
What is the current behavior? The current behaviour while using the latest version of react-dropzone (10.1.5) is the following error on attempting to render the component in a class component using the example in the docs.
Uncaught Invariant Violation: Invalid hook call. Hooks can only be called inside of the body of a function component.
The above error occurred in the <Dropzone> component: in Dropzone
export class UploadFile extends React.Component {
render() {
return (
<Dropzone onDrop={acceptedFiles => console.log(acceptedFiles)}>
{({ getRootProps, getInputProps }) => (
<section>
<div
{...getRootProps({
accept: "application/pdf,image/jpg,image/jpeg,image/png",
multiple: true
})}
>
<input {...getInputProps()} />
<p>Drop files here</p>
</div>
</section>
)}
</Dropzone>
);
}
Issue Analytics
- State:
- Created 4 years ago
- Reactions:5
- Comments:17
Top Results From Across the Web
Error: Invalid hook call. Hooks can only be called inside of the ...
Error: Invalid hook call. Hooks can only be called inside of the body of a function component. : react-dropzone · You might have...
Read more >Invalid Hook Call Warning - React
Invalid Hook Call Warning. You are probably here because you got the following error message: Hooks can only be called inside the body...
Read more >react-dropzone
Simple React hook to create a HTML5-compliant drag'n'drop zone for files. Documentation and examples at https://react-dropzone.js.org.
Read more >uncaught error: invalid hook call. hooks can only be called inside of ...
react.development.js:1476 Uncaught Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for...
Read more >Create a drag-and-drop with react-dropzone - LogRocket Blog
react -dropzone uses React hooks to create HTML5-compliant React ... the name of file } else { // add a new property called...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@rolandjitsu in my project, react & react-dom are at the same version i.e 16.8.6, but I’m still facing the same issue.
I don’t know if this will help anyone , but in my case i had initially installed the package in my root folder, so the structure was like inside root project there was the Front end project and back-end project all npm , there were no import error even though it was in root.But while rendering it would throw the invalid hook issue. But when i reinstalled it in my FE project it worked fine