File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -130,6 +130,7 @@ Change valueExtractor and pass the data to Autocomplete without fetchDataUrl
130130
131131 name | description | type | default
132132:----------------- |:--------------------------------------------- | --------:|:------------------
133+ ref | Used to access component methods ("clearInput" for example) | RefObject | -
133134 autoCorrect | Disable auto-correct | Boolean | true
134135 keyboardType | Input Keyboard Type | String | default
135136 highlightText | Highlight search results | Boolean | true
@@ -170,6 +171,28 @@ Change valueExtractor and pass the data to Autocomplete without fetchDataUrl
170171 rightTextExtractor | Extract value from item (args: item, index) | Function | ({ value }) => value
171172 fetchData | Fetch data for autocomplete | Function | -
172173
174+
175+ ## Methods
176+
177+ You can use methods through ` ref ` property:
178+ ``` javascript
179+ ...
180+ const componentRef = useRef ()
181+ < Autocomplete
182+ ref= {componentRef}
183+ ...
184+ / >
185+ ...
186+ componentRef .current .clearInput ()
187+ ```
188+
189+ ### Methods list
190+
191+ method | description | return
192+ :----------------- |:---------------------------------------------:|:-------
193+ clearInput | Clears input value | -
194+
195+
173196## Contributors ✨
174197
175198Thanks goes to these wonderful people ([ emoji key] ( https://allcontributors.org/docs/en/emoji-key ) ):
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ class Autocomplete extends Component {
2626 this . handleInputChange = this . handleInputChange . bind ( this ) ;
2727 this . handleBlur = this . handleBlur . bind ( this ) ;
2828 this . promisifySetState = this . promisifySetState . bind ( this ) ;
29+ this . clearInput = this . clearInput . bind ( this ) ;
2930 }
3031
3132 handleInputChange ( text ) {
@@ -128,6 +129,10 @@ class Autocomplete extends Component {
128129 }
129130 }
130131
132+ clearInput ( ) {
133+ this . setState ( { inputValue : "" } ) ;
134+ }
135+
131136 componentDidMount ( ) {
132137 const { data} = this . props ;
133138 this . mounted = true ;
You can’t perform that action at this time.
0 commit comments