Skip to content

Instantly share code, notes, and snippets.

@myogeshchavan97
Last active April 6, 2021 05:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save myogeshchavan97/a80b698f75079633e75e3cc847ec5065 to your computer and use it in GitHub Desktop.
Save myogeshchavan97/a80b698f75079633e75e3cc847ec5065 to your computer and use it in GitHub Desktop.
useContext Updated Filters.js
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