Last active
April 6, 2021 05:40
-
-
Save myogeshchavan97/a80b698f75079633e75e3cc847ec5065 to your computer and use it in GitHub Desktop.
useContext Updated Filters.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useContext } from 'react'; | |
import Select from 'react-select'; | |
import UserContext from '../context/UserContext'; | |
const Filters = ({ handleSort }) => { | |
const { sortOrder } = useContext(UserContext); | |
const options = [ | |
{ value: '', label: 'None' }, | |
{ value: 'asc', label: 'Ascending' }, | |
{ value: 'desc', label: 'Descending' } | |
]; | |
return ( | |
<div className="sortBy"> | |
Sort by age | |
<Select | |
value={sortOrder} | |
className="select-filter" | |
onChange={handleSort} | |
options={options} | |
/> | |
</div> | |
); | |
}; | |
export default Filters; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment