Last active
April 6, 2021 05:36
-
-
Save myogeshchavan97/d9bf8141183fefd6fa492272253ffcdb to your computer and use it in GitHub Desktop.
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 from 'react'; | |
import Select from 'react-select'; | |
import UserContext from '../context/UserContext'; | |
const Filters = ({ handleSort }) => { | |
const options = [ | |
{ value: '', label: 'None' }, | |
{ value: 'asc', label: 'Ascending' }, | |
{ value: 'desc', label: 'Descending' } | |
]; | |
return ( | |
<UserContext.Consumer> | |
{({ sortOrder }) => ( | |
<div className="sortBy"> | |
Sort by age | |
<Select | |
value={sortOrder} | |
className="select-filter" | |
onChange={handleSort} | |
options={options} | |
/> | |
</div> | |
)} | |
</UserContext.Consumer> | |
); | |
}; | |
export default Filters; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment