Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
react-native-autocomplete-input
Advanced tools
A pure JS autocomplete component for React Native written in TypeScript. Use this component in your own projects or use it as inspiration to build your own autocomplete.
Play around with the Example Snack
# Install with npm
$ npm install --save react-native-autocomplete-input
# Install with yarn
$ yarn add react-native-autocomplete-input
function MyComponent() {
const [ query, setQuery ] = useState('');
const data = useFilteredData(query);
return (
<Autocomplete
data={data}
value={query}
onChangeText={(text) => setQuery(text)}
flatListProps={{
keyExtractor: (_, idx) => idx,
renderItem: ({ item }) => <Text>{item}</Text>,
}}
/>
);
}
Android does not support overflows (#20), for that reason it is necessary to wrap the autocomplete into a absolute positioned view on Android. This will allow the suggestion list to overlap other views inside your component.
function MyComponent() {
return (
<View>
<View style={styles.autocompleteContainer}>
<Autocomplete {/* your props */} />
</View>
<View>
<Text>Some content</Text>
</View>
</View>
);
}
const styles = StyleSheet.create({
autocompleteContainer: {
flex: 1,
left: 0,
position: 'absolute',
right: 0,
top: 0,
zIndex: 1
}
});
Prop | Type | Description |
---|---|---|
containerStyle | style | These styles will be applied to the container which surrounds the autocomplete component. |
hideResults | bool | Set to true to hide the suggestion list. |
data | array | An array with suggestion items to be rendered in renderItem({ item, i }) . Any array with length > 0 will open the suggestion list and any array with length < 1 will hide the list. |
inputContainerStyle | style | These styles will be applied to the container which surrounds the textInput component. |
listContainerStyle | style | These styles will be applied to the container which surrounds the result list. |
listStyle | style | These style will be applied to the result list. |
onShowResults | function | onShowResults will be called when the autocomplete suggestions appear or disappear. |
onStartShouldSetResponderCapture | function | onStartShouldSetResponderCapture will be passed to the result list view container (onStartShouldSetResponderCapture). |
renderTextInput | function | render custom TextInput. All props passed to this function. |
flatListProps | object | custom props to FlatList. |
renderResultList | function | render custom result list. Can be used to replace FlatList. All props passed to this function. |
<ScrollView />
. Set the scroll view's prop to fix this: keyboardShouldPersistTaps={true}
for RN <= 0.39, or keyboardShouldPersistTaps='always'
for RN >= 0.40. (#5). Alternatively, you can use renderResultList to render a custom result list that does not use FlatList. See the tests for an example.jest.mock('react-native-autocomplete-input', () => 'Autocomplete');
to your test.Feel free to open issues or submit a PR!
FAQs
Pure javascript autocomplete input for react-native
We found that react-native-autocomplete-input demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.