This commit is contained in:
AllenFang 2018-09-29 14:31:10 +08:00
parent d4fa9a84e3
commit 0cdf086d56
2 changed files with 4 additions and 1 deletions

View File

@ -17,6 +17,7 @@ class ToolkitProvider extends statelessDrcorator(React.Component) {
search: PropTypes.oneOfType([
PropTypes.bool,
PropTypes.shape({
defaultSearch: PropTypes.string,
searchFormatted: PropTypes.bool
})
]),
@ -42,7 +43,7 @@ class ToolkitProvider extends statelessDrcorator(React.Component) {
constructor(props) {
super(props);
this.state = {
searchText: ''
searchText: typeof props.search === 'object' ? (props.search.defaultSearch || '') : ''
};
this._ = null;
this.onSearch = this.onSearch.bind(this);
@ -85,6 +86,7 @@ class ToolkitProvider extends statelessDrcorator(React.Component) {
return (
<ToolkitContext.Provider value={ {
searchProps: {
searchText: this.state.searchText,
onSearch: this.onSearch
},
csvProps: {

View File

@ -47,6 +47,7 @@ const SearchBar = ({
style={ style }
onKeyUp={ () => debounceCallback() }
className={ `form-control ${className}` }
defaultValue={ searchText }
placeholder={ placeholder || SearchBar.defaultProps.placeholder }
{ ...rest }
/>