From 9a443cf5ed5c01d8919d0129458e49f2645097e9 Mon Sep 17 00:00:00 2001 From: Nikolay Lanets Date: Fri, 27 Apr 2018 13:06:29 +0300 Subject: [PATCH 1/2] Custom renderer for debug info --- lib/Autocomplete.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/Autocomplete.js b/lib/Autocomplete.js index 1658c8bb..c4425749 100644 --- a/lib/Autocomplete.js +++ b/lib/Autocomplete.js @@ -157,6 +157,11 @@ class Autocomplete extends React.Component { */ open: PropTypes.bool, debug: PropTypes.bool, + /** + * Arguments: `renderer: Function` + * Custom renderer for debug info + */ + renderDebug: PropTypes.func, } static defaultProps = { @@ -188,6 +193,11 @@ class Autocomplete extends React.Component { autoHighlight: true, selectOnBlur: false, onMenuVisibilityChange() {}, + renderDebug: function(debugStates){ + return
+        {JSON.stringify(debugStates.slice(Math.max(0, debugStates.length - 5), debugStates.length), null, 2)}
+      
+ } } constructor(props) { @@ -568,7 +578,7 @@ class Autocomplete extends React.Component { }) } - const { inputProps } = this.props + const { inputProps, renderDebug } = this.props const open = this.isOpen() return (
@@ -587,11 +597,7 @@ class Autocomplete extends React.Component { value: this.props.value, })} {open && this.renderMenu()} - {this.props.debug && ( -
-            {JSON.stringify(this._debugStates.slice(Math.max(0, this._debugStates.length - 5), this._debugStates.length), null, 2)}
-          
- )} + {this.props.debug && renderDebug ? renderDebug(this._debugStates) : null}
) } From 0e8f1356ee13288aa524500b06ac0e92a7cb7ccc Mon Sep 17 00:00:00 2001 From: Nikolay Lanets Date: Fri, 27 Apr 2018 13:15:31 +0300 Subject: [PATCH 2/2] Update Autocomplete.js --- lib/Autocomplete.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Autocomplete.js b/lib/Autocomplete.js index c4425749..fd9092ef 100644 --- a/lib/Autocomplete.js +++ b/lib/Autocomplete.js @@ -193,7 +193,7 @@ class Autocomplete extends React.Component { autoHighlight: true, selectOnBlur: false, onMenuVisibilityChange() {}, - renderDebug: function(debugStates){ + renderDebug: function (debugStates) { return
         {JSON.stringify(debugStates.slice(Math.max(0, debugStates.length - 5), debugStates.length), null, 2)}