Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // контекст
- const SearchState = props => {
- const initialState = {
- location: {
- value: '',
- isEnabled: false
- },
- language: {
- value: '',
- isEnabled: false
- },
- repos: {
- value: 1,
- isEnabled: false
- }
- };
- const [state, dispatch] = useReducer(SearchReducer, initialState);
- const getLocation = () => {
- return state.location;
- };
- // компонент
- const FilterLocation = () => {
- const searchContext = useContext(SearchContext);
- const location = searchContext.getLocation();
- const locationOnChange = e => {
- // setFilters({ ...filters, location: e.target.value });
- searchContext.setLocation(e.target.value);
- };
- return (
- <label
- className={`filter location-filter ${
- location.isEnabled ? 'filter-active' : 'filter-disabled'
- }`}
- filter='location'
- htmlFor='location'
- >
- <FilterTitle name={'location'} isChecked={location.isEnabled} />
- <input
- disabled={!location.isEnabled}
- type='text'
- id='location-value'
- name='location-value'
- placeholder='Location...'
- onChange={locationOnChange}
- // disabled
- value={location.value}
- />
- </label>
- );
- };
Advertisement
Add Comment
Please, Sign In to add comment