Skip to content

Commit

Permalink
Merge pull request #236 from goldylucks/patch-2
Browse files Browse the repository at this point in the history
docs(readme): add examples of exposed functions
  • Loading branch information
ro-ka authored Dec 14, 2016
2 parents 0b9e2ac + 945352c commit d706366
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ All [DOM mouse events](https://facebook.github.io/react/docs/events.html#mouse-e


### Exposed component functions
These functions are accessible by setting "ref" on the component (see example below)

#### focus()
Call `focus` to focus on the element. The suggest list will be expanded with the current suggestions.
Expand Down Expand Up @@ -268,12 +269,18 @@ var App = React.createClass({
return (
<div>
<Geosuggest
ref={el=>this._geoSuggest=el}
placeholder="Start typing!"
initialValue="Hamburg"
fixtures={fixtures}
onSuggestSelect={this.onSuggestSelect}
location={new google.maps.LatLng(53.558572, 9.9278215)}
radius="20" />

{* Buttons to trigger exposed component functions *}
<button onClick={()=>this._geoSuggest.focus()}>Focus</button>
<button onClick={()=>this._geoSuggest.update('New Zeland')}>Update</button>
<button onClick={()=>this._geoSuggest.clear()}>Clear</button>
</div>
)
},
Expand Down

0 comments on commit d706366

Please sign in to comment.