Search input onchange causes crashing – how to make it a button to submit search

I have an app in MeteorJS, which makes use of React (I am ok with JavaScript, but am on a learning curve starting with React). The current search input makes use of the onchange function of the input box BUT this is actually not desired as this slows the app considerably – making requests every time the user types.

I basically want the input to be basic input and then have a button to trigger the search.

Inline code, for calling the searchinput where needed;

<div className="col-md-4 col-xs-12" style={disabledStyling.control}>
    <SearchInput placeholder="Search" onChange={this.filterGames} value={filter} />
</div>

searchinput component;

import PropTypes from 'prop-types';
import Icon from '../Icon';
import Styles from './styles';

const SearchInput = ({ placeholder, value, onChange }) => (
  <Styles.SearchInput className="SearchInput">
    <Icon iconStyle="solid" icon="search" />
    <input
      type="text"
      name="search"
      className="form-control"
      placeholder={placeholder}
      value={value}
      onChange={onChange}
    />
  </Styles.SearchInput>
);

SearchInput.defaultProps = {
  placeholder: 'Search...',
  value: '',
};

SearchInput.propTypes = {
  placeholder: PropTypes.string,
  value: PropTypes.string,
  onChange: PropTypes.func.isRequired,
};

export default SearchInput;

Hoping you all could help 😉

164 thoughts on “Search input onchange causes crashing – how to make it a button to submit search”

  1. Pingback: cialis alternative
  2. Pingback: viagra canada
  3. Pingback: free viagra
  4. Pingback: cialis capsule
  5. Pingback: cialis mg
  6. Pingback: cialis generic
  7. Pingback: canadian viagra
  8. Pingback: gtrviagraok
  9. Pingback: cialis canada
  10. Pingback: viagra connect
  11. Pingback: viagra online usa
  12. Pingback: sildenafil generic
  13. Pingback: sildenafil 100mg
  14. Pingback: viagra cost
  15. Pingback: cost of viagra
  16. Pingback: viagra sildenafil
  17. Pingback: herb viagra
  18. Pingback: viagra vs.levitra
  19. Pingback: cost for viagra
  20. Pingback: viagra walmart
  21. Pingback: lady viagra
  22. Pingback: viagra pills
  23. Pingback: female viagra
  24. Pingback: sildenafil citrate
  25. Pingback: viagra for sale
  26. Pingback: cialis tablet

Leave a Comment