Skip to content

Commit

Permalink
add default query prop
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean Houlihan committed Jul 8, 2019
1 parent eee65d4 commit 2fc0e89
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@seanhouli/react-mapbox-search",
"version": "1.0.3",
"version": "1.0.4",
"description": "A location picker component that uses Mapbox's places API to provide location suggestions",
"main": "dist/index",
"scripts": {
Expand Down
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,4 @@ import SearchBox from "@seanhouli/react-mapbox-search";
| callback | function | undefined | Callback function fired when suggestion chosen |
| selectColor | string | "#58A" | Color for currently selected suggestion item |
| searchHint | string | "Search" | Placeholder text for input when empty |
| query | string | "" | Default query to populate input |
12 changes: 9 additions & 3 deletions src/Components/SearchBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class SearchBox extends React.Component {
constructor(props) {
super(props);
this.state = {
query: "",
query: props.query,
queryResults: [],
cursorIdx: 0,
getMouseInSuggestions: false,
Expand Down Expand Up @@ -188,14 +188,20 @@ SearchBox.propTypes = {
/**
* hint text for input
*/
searchHint: PropTypes.string
searchHint: PropTypes.string,

/**
* default query text
*/
query: PropTypes.string
};

SearchBox.defaultProps = {
country: undefined,
selectColor: "#58a",
callback: undefined,
searchHint: "Search"
searchHint: "Search",
query: ""
};

export default SearchBox;

0 comments on commit 2fc0e89

Please sign in to comment.