react-searchbox is a simple Searchbox component with events for keychange, searching and clearing.
yarn add react-searchbox
import Search from 'react-searchbox'
import ReactDOM from 'react-dom'
import React, { Component } from 'react'
class TestComponent extends Component {
clear() {
console.log('clearing...')
}
search() {
console.log('searching...')
}
change(key) {
console.log('key change...')
console.log(key)
}
constructor(props) {
super(props)
}
render() {
return (
<div style={{ padding: '20px', maxWidth: '400px' }}>
<Search
inputName="my-input"
placeholder="Search for something..."
onClearClick={this.clear.bind(this)}
onSearchClick={this.search.bind(this)}
onKeyChange={this.change.bind(this)}
/>
</div>
)
}
}
ReactDOM.render(<TestComponent />, document.getElementById('root'))
The name of the input element
The placeholder for the input element
Focus the input element on component mount if set to true.
Handler for the click event of the search button, returns the search value.
Handler for the onKeyUp event on the input element, returns the search value.
Handler for the click event of the clear button, returns the search value.
react-searchbox can be used with your own custom styles. A minimal react-searchbox.css style sheet is included.
yarn
yarn dev
yarn test
yarn
yarn build
npm login
npm version patch
git add -A
git push origin master
npm publish