@@ -7,13 +7,10 @@ const Acronym = (props) => {
77 < acronym
88 onClick = { ( ) => {
99 if ( props . setProps ) {
10- const newProps = {
11- n_clicks : props . n_clicks + 1
12- }
13- if ( newProps . n_clicks > 1 ) {
14- newProps . n_clicks_previous = props . n_clicks_previous + 1 ;
15- }
16- props . setProps ( newProps ) ;
10+ props . setProps ( {
11+ n_clicks : props . n_clicks + 1 ,
12+ n_clicks_timestamp : Date . now ( )
13+ } )
1714 }
1815 if ( props . fireEvent ) props . fireEvent ( { event : 'click' } ) ;
1916 } }
@@ -26,7 +23,7 @@ const Acronym = (props) => {
2623
2724Acronym . defaultProps = {
2825 n_clicks : 0 ,
29- n_clicks_previous : 0
26+ n_clicks_timestamp : - 1
3027} ;
3128
3229Acronym . propTypes = {
@@ -49,15 +46,11 @@ Acronym.propTypes = {
4946 'n_clicks' : PropTypes . integer ,
5047
5148 /**
52- * An integer that represents the number of times
53- * that this element was clicked on. If this is the same as
54- * `n_clicks`, then the button wasn't clicked on.
55- * If it is less than `n_clicks`, then the button
56- * was clicked on. This is useful in callbacks that have
57- * multiple buttons and you need to know _which_ button
58- * was clicked on.
59- */
60- 'n_clicks_previous' : PropTypes . integer ,
49+ * An integer that represents the time (in ms since 1970)
50+ * at which n_clicks changed. This can be used to tell
51+ * which button was changed most recently.
52+ */
53+ 'n_clicks_timestamp' : PropTypes . integer ,
6154
6255 /**
6356 * A unique identifier for the component, used to improve
0 commit comments