[GH-ISSUE #9] Use React event naming conventions #5

Closed
opened 2026-05-05 11:22:27 -06:00 by gitea-mirror · 12 comments
Owner

Originally created by @gaearon on GitHub (Feb 17, 2018).
Original GitHub issue: https://github.com/kusti8/proton-native/issues/9

In React, events are typically called onChange and onClick rather than onChanged and onClicked. How do you feel about changing this? Great project btw!

Originally created by @gaearon on GitHub (Feb 17, 2018). Original GitHub issue: https://github.com/kusti8/proton-native/issues/9 In React, events are typically called `onChange` and `onClick` rather than `onChanged` and `onClicked`. How do you feel about changing this? Great project btw!
Author
Owner

@kusti8 commented on GitHub (Feb 18, 2018):

I would rather keep it closer to libui-node, since that simplifies it a lot. If you want to, you can map them, but I think it's too much work and would make the code more confusing.

<!-- gh-comment-id:366484574 --> @kusti8 commented on GitHub (Feb 18, 2018): I would rather keep it closer to libui-node, since that simplifies it a lot. If you want to, you can map them, but I think it's too much work and would make the code more confusing.
Author
Owner

@gaearon commented on GitHub (Feb 18, 2018):

I see. In that case it would make sense to provide a helpful error message. Currently if you pass onClick it just fails somewhere in internals.

<!-- gh-comment-id:366484702 --> @gaearon commented on GitHub (Feb 18, 2018): I see. In that case it would make sense to provide a helpful error message. Currently if you pass `onClick` it just fails somewhere in internals.
Author
Owner

@kusti8 commented on GitHub (Feb 18, 2018):

Yeah one of my goals is to add error messages

<!-- gh-comment-id:366486487 --> @kusti8 commented on GitHub (Feb 18, 2018): Yeah one of my goals is to add error messages
Author
Owner

@zaguiini commented on GitHub (Feb 18, 2018):

I don't think you should keep it closer to libui-node since you're implementing React and you know, there are a lot of conventions... Doesn't make sense to me. In the whole React world (DOM, Native, etcetera), we are used to things like onClick, onPress and so forth.

<!-- gh-comment-id:366540040 --> @zaguiini commented on GitHub (Feb 18, 2018): I don't think you should keep it closer to libui-node since you're implementing React and you know, there are a lot of conventions... Doesn't make sense to me. In the whole React world (DOM, Native, etcetera), we are used to things like `onClick`, `onPress` and so forth.
Author
Owner

@joaoeffting commented on GitHub (Feb 20, 2018):

I thougth the same when I saw onClicked :D

But the library is so cool that I didn't mind :p

<!-- gh-comment-id:366959783 --> @joaoeffting commented on GitHub (Feb 20, 2018): I thougth the same when I saw onClicked :D But the library is so cool that I didn't mind :p
Author
Owner

@kusti8 commented on GitHub (Feb 20, 2018):

Yeah I've decided that I'll do it when I get a chance.

<!-- gh-comment-id:367020208 --> @kusti8 commented on GitHub (Feb 20, 2018): Yeah I've decided that I'll do it when I get a chance.
Author
Owner

@benwiley4000 commented on GitHub (Feb 22, 2018):

Here's a regex you can use to search for all the instances where this is happening:

on[A-Z][a-z]+(ed|ing)
  • onChanged -> onChange
  • onClosing -> onClose
  • onClicked -> onClick
  • onToggled -> onToggle
  • onSelected -> onSelect
  • onContentSizeChanged -> onContentSizeChange
  • onPositionChanged -> onPositionChange

Probably a good idea to deprecate those props in this version (but still accept them and emit warning messages) and remove them for good in version 2, whenever that gets released.

<!-- gh-comment-id:367771923 --> @benwiley4000 commented on GitHub (Feb 22, 2018): Here's a regex you can use to search for all the instances where this is happening: ```regex on[A-Z][a-z]+(ed|ing) ``` * `onChanged` -> `onChange` * `onClosing` -> `onClose` * `onClicked` -> `onClick` * `onToggled` -> `onToggle` * `onSelected` -> `onSelect` * `onContentSizeChanged` -> `onContentSizeChange` * `onPositionChanged` -> `onPositionChange` Probably a good idea to deprecate those props in this version (but still accept them and emit warning messages) and remove them for good in version 2, whenever that gets released.
Author
Owner

@kusti8 commented on GitHub (Feb 22, 2018):

Yeah I'm going to create a mapping for all of the callbacks, and it should
be very simple. Just an object of all the functions in DesktopComponent.js
and then change it in update and initialProps. I just need to find the time
to do it.

On Thu, Feb 22, 2018, 1:17 PM Ben Wiley notifications@github.com wrote:

Here's a regex you can use to search for all the instances where this is
happening:

on[A-Z][a-z]+(ed|ing)

  • onChanged -> onChange
  • onClosing -> onClose
  • onClicked -> onClick
  • onToggled -> onToggle
  • onSelected -> onSelect
  • onContentSizeChanged -> onContentSizeChange
  • onPositionChanged -> onPositionChange


You are receiving this because you modified the open/close state.

Reply to this email directly, view it on GitHub
https://github.com/kusti8/proton-native/issues/9#issuecomment-367771923,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AJW73PcMRNReU5j5N2afW-2Y4vqVk2bgks5tXa8zgaJpZM4SJZgS
.

<!-- gh-comment-id:367775645 --> @kusti8 commented on GitHub (Feb 22, 2018): Yeah I'm going to create a mapping for all of the callbacks, and it should be very simple. Just an object of all the functions in DesktopComponent.js and then change it in update and initialProps. I just need to find the time to do it. On Thu, Feb 22, 2018, 1:17 PM Ben Wiley <notifications@github.com> wrote: > Here's a regex you can use to search for all the instances where this is > happening: > > on[A-Z][a-z]+(ed|ing) > > > - onChanged -> onChange > - onClosing -> onClose > - onClicked -> onClick > - onToggled -> onToggle > - onSelected -> onSelect > - onContentSizeChanged -> onContentSizeChange > - onPositionChanged -> onPositionChange > > — > You are receiving this because you modified the open/close state. > > > Reply to this email directly, view it on GitHub > <https://github.com/kusti8/proton-native/issues/9#issuecomment-367771923>, > or mute the thread > <https://github.com/notifications/unsubscribe-auth/AJW73PcMRNReU5j5N2afW-2Y4vqVk2bgks5tXa8zgaJpZM4SJZgS> > . >
Author
Owner

@kusti8 commented on GitHub (Feb 23, 2018):

I've decided to just replace them instead of deprecate them, because this is pretty beta, and I want to fix it quickly, and not cause more confusion

<!-- gh-comment-id:367902694 --> @kusti8 commented on GitHub (Feb 23, 2018): I've decided to just replace them instead of deprecate them, because this is pretty beta, and I want to fix it quickly, and not cause more confusion
Author
Owner

@benwiley4000 commented on GitHub (Feb 23, 2018):

@kusti8 Thanks for the update! It could be good to document that breaking changes can be expected. Since the package.json is past 1.0, I was assuming 1.x.x shouldn't introduce any breaking changes, and I suspect others might think the same.

<!-- gh-comment-id:367914262 --> @benwiley4000 commented on GitHub (Feb 23, 2018): @kusti8 Thanks for the update! It could be good to document that breaking changes can be expected. Since the package.json is past 1.0, I was assuming 1.x.x shouldn't introduce any breaking changes, and I suspect others might think the same.
Author
Owner

@haltcase commented on GitHub (Feb 27, 2018):

I'm with @benwiley4000 here. Obviously the ship has sailed on doing 0.x releases, so since you're already over 1.x this is a pretty overt semver violation. I would definitely not expect upgrading from 1.0.11 to 1.0.12 to introduce this kind of breaking change.

<!-- gh-comment-id:368719010 --> @haltcase commented on GitHub (Feb 27, 2018): I'm with @benwiley4000 here. Obviously the ship has sailed on doing `0.x` releases, so since you're already over 1.x this is a pretty overt semver violation. I would definitely not expect upgrading from `1.0.11` to `1.0.12` to introduce this kind of breaking change.
Author
Owner

@kusti8 commented on GitHub (Mar 2, 2018):

Yeah I forgot about semvar. I won't change anything now, but i'll keep it in mind for the future.

<!-- gh-comment-id:369800468 --> @kusti8 commented on GitHub (Mar 2, 2018): Yeah I forgot about semvar. I won't change anything now, but i'll keep it in mind for the future.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/proton-native#5
No description provided.