-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to Implement it with functional component #81
Comments
hey people how can I change this class component into functional component |
simple example with functional components import React, {useState, Fragment} from 'react';
import SearchableDropdown from 'react-native-searchable-dropdown';
const items = [
{id: 1, name: 'JavaScript',},
{id: 2, name: 'Java',},
{id: 3, name: 'Ruby',},
{id: 4, name: 'React Native',},
{id: 5, name: 'PHP',},
{id: 6, name: 'Python',},
{id: 7, name: 'Go',},
{id: 8, name: 'Swift',},
];
const App: () => Node = () => {
const [selectedItems, setSelectedItems] = useState([]);
const addItem = (item) => {
setSelectedItems(item)
}
return (
<Fragment>
<SearchableDropdown
containerStyle={{ padding: 5, width: '40%' }}
selectedItems={selectedItems}
onTextChange={text => console.log(text)}
onItemSelect={addItem}
items={items}
defaultIndex={1}
textInputStyle={{
padding: 12,
borderWidth: 1,
borderColor: '#ccc',
backgroundColor: '#FAF7F6',
}}
itemStyle={{
padding: 10,
marginTop: 2,
backgroundColor: '#FAF9F8',
borderColor: '#bbb',
borderWidth: 1,
}}
itemTextStyle={{
color: '#222',
}}
itemsContainerStyle={{
maxHeight: '80%',
}}
resetValue={false}
>
</SearchableDropdown>
</Fragment>
);
};
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
No description provided.
The text was updated successfully, but these errors were encountered: