diff --git a/package.json b/package.json index 91da867..fd47fb1 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/readme.md b/readme.md index 22ea7b0..beb8193 100644 --- a/readme.md +++ b/readme.md @@ -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 | diff --git a/src/Components/SearchBox.js b/src/Components/SearchBox.js index 855f76c..52cbada 100644 --- a/src/Components/SearchBox.js +++ b/src/Components/SearchBox.js @@ -24,7 +24,7 @@ class SearchBox extends React.Component { constructor(props) { super(props); this.state = { - query: "", + query: props.query, queryResults: [], cursorIdx: 0, getMouseInSuggestions: false, @@ -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;