Skip to content

Instantly share code, notes, and snippets.

@jkomyno
Created July 14, 2017 10:33
Show Gist options
  • Save jkomyno/c11544a76fc55dc0a413c33282026943 to your computer and use it in GitHub Desktop.
Save jkomyno/c11544a76fc55dc0a413c33282026943 to your computer and use it in GitHub Desktop.
Platform consistent SearchBar component for react-native
import React from 'react';
import PropTypes from 'prop-types';
import SearchBar from 'react-native-material-design-searchbar';
const SearchBar = ({ onChangeText, onBackButtonPress, placeholder }) => (
<SearchBar
onSearchChange={onChangeText}
placeholder={placeholder}
onBackPress={onBackButtonPress}
height={50}
autoCorrect={false}
returnKeyType="search"
/>
);
SearchBar.propTypes = {
onChangeText: PropTypes.func.isRequired,
onBackButtonPress: PropTypes.func.isRequired,
placeholder: PropTypes.string.isRequired,
};
export default SearchBar;
import React from 'react';
import PropTypes from 'prop-types';
import SearchBar from 'react-native-search-bar';
const SearchBar = ({ onChangeText, onBackButtonPress, placeholder }) => (
<SearchBar
ref="searchBar"
placeholder={placeholder}
onChangeText={onChangeText}
onCancelButtonPress={onBackButtonPress}
/>
);
SearchBar.propTypes = {
onChangeText: PropTypes.func.isRequired,
onBackButtonPress: PropTypes.func.isRequired,
placeholder: PropTypes.string.isRequired,
};
export default SearchBar;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment