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
I recently ran into #1711, which has been fixed in a more recent version of the package. However, I was curious if there is any documentation or discussion around this behaviour of automatically wrapping any function that begins with the word on, and why the library is doing that.
It was really surprising to me to discover this issue, since I had a component being rendered inside of a Dialog that was taking a custom (non-event-related) onDelete handler. It was meant as a callback to signify when a "delete" button had been pressed, and was not called with any args.
I ran into the exact issue from above, and had to work backwards to figure out that it was only happening when the function was named onDelete, but worked fine for something like handleDelete. That was really strange, and had me digging in the source code until I could find the place where this automatic wrapping was being done
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello,
I recently ran into #1711, which has been fixed in a more recent version of the package. However, I was curious if there is any documentation or discussion around this behaviour of automatically wrapping any function that begins with the word
on
, and why the library is doing that.It was really surprising to me to discover this issue, since I had a component being rendered inside of a Dialog that was taking a custom (non-event-related)
onDelete
handler. It was meant as a callback to signify when a "delete" button had been pressed, and was not called with any args.I ran into the exact issue from above, and had to work backwards to figure out that it was only happening when the function was named
onDelete
, but worked fine for something likehandleDelete
. That was really strange, and had me digging in the source code until I could find the place where this automatic wrapping was being doneheadlessui/packages/@headlessui-react/src/utils/render.ts
Line 207 in 5af3bd4
Would be curious to see what's going on here and if there's any docs or best practices around this behaviour.
Beta Was this translation helpful? Give feedback.
All reactions