eventProxy() TypeError (Preact X)
See original GitHub issueNot sure if this is intended or not but while porting over legacy jQuery code to Preact X I ran into this cryptic error message:
preact.mjs?e1dc:1 Uncaught TypeError: this.n[n.type] is not a function
at HTMLImageElement.k
I found out that it was caused by an old onError
prop
<img onError="/* jquery stuff */" />
Could probably do a more explicit type check here but not sure if it is worth the bytes. Happy to add a PR if desired
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
eventProxy() TypeError (Preact X) · Issue #1350 - GitHub
This is a good candidate for our debug addon that lives in preact/debug . They are build to warn in case of bad...
Read more >What's new in Preact X
New features and changes in Preact X. ... The createContext -API is a true successor for getChildContext() . Whereas getChildContext is fine when...
Read more >Switching to Preact (from React)
This is the recommended way to try out Preact if you have an existing React app. This lets you continue writing React/ReactDOM code...
Read more >Hooks | Preact: Fast 3kb React alternative with the same ES6 ...
They both use the useCounter() custom hook, but each has its own instance of that hook's associated state. Thinking this looks a little...
Read more >Refs | Preact: Fast 3kb React alternative with the same ES6 ...
current // an HTML <input> element input.current.focus() // focus the input! Using createRef() ...
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
It would mean non-function values never get assigned as handlers. TBH the one drawback here is that it would prevent Preact from ever supporting DOM EventHandler interface:
One way to work around this would be to check for non-strings instead of checking for functions:
However, all of these solutions get tricky due to the possibility that the type will change:
In the second render above,
.onclick
is never unset.Might also be worth considering this suggestion from @uppercod:
https://twitter.com/Uppercod/status/1103336598178013186
Interestingly, it would make the jQuery stuff still work in this case.