-
-
Notifications
You must be signed in to change notification settings - Fork 186
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
Cannot read property 'isReactComponent' of undefined #327
Comments
Could I ask you to add a minimal bit of code that shows this happening? Especially given that the indicated line is an empty line between a |
Our set up is based exactly on your hooks example. We have an older app that still works, but if you create a new app with CRA and add react-onclickoutside as a dependency, then set up a simple example it will fail every time. We tested with older versions of React, duplicating existing projects and more. We used this example...
|
Same issue for me with functional component, with these dependencies : "react-onclickoutside": "6.9.0" Works only if the component is created with the "function" keyword |
We encountered this same error happening on this line of code in I haven't had time yet to narrow down exactly when this is the case, but in our situation, it appeared to happen when the wrapped component was a React forwardRef component. |
To add more details, React return {
$$typeof: REACT_FORWARD_REF_TYPE,
render,
}; Whereas class objects and functions do, so they don't cause the above issue. Other components, like |
I ran into the same problem, when using next.js and a function component in this case. To workaround the issue I added a "prototype" field.. Edit: I was also using server side rendering where the error happened. MyFunctionComponent.prototype = {} Edit: @pedro-lb made the example more clear. |
Also having this problem with funcional components. I'm following the example.
doesn't solve it for me. |
Using Gatsby, I also ran into this issue on running |
I ran into this issue and checked the source code for further details...
here though |
@dreamerchandra I am also using functional components. Try adding the line after your functional component ends, like so |
I went back to using class components when using this package. This package really isn't ready for functional components anyways, as you cannot have multiple functional components render on the same page. |
I migrated to this solution for functional components: https://usehooks.com/useOnClickOutside/ |
@jRichardeau thanks your suggestion worked for me! CRA using hooks
|
In my case, using function instead of arrow function solved this issue |
can someone explain why here -> https://codesandbox.io/s/vn66kq7mml?file=/src/Menu.js |
I removed this package, it's super strange when the example works and your code does not, relying on the same logic. |
This worked for me. However, it's strange how many people are all having this issue and it doesn't seem like any dev support has been given, since the docs say something like "only the latest versions of react will get updates and bug fixes." |
the best way to handle without this lib is this https://ahooks.js.org/hooks/dom/use-click-away/ |
Working for me in gatsby build |
react-onclickoutside.es.js:329
New (13/08/19) NPX CRA build with react-onclickoutside - fails as soon as the functional component is wrapped.
The text was updated successfully, but these errors were encountered: