Download Airbnb_clone/src/Search.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.25 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/f5071caa249115f3b590492f1c8eb471e02aae4b/Airbnb_clone/src/Search.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@f5071caa249115f3b590492f1c8eb471e02aae4b/Airbnb_clone/src/Search.js
-
curl -L -o Search.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/f5071caa249115f3b590492f1c8eb471e02aae4b/Airbnb_clone/src/Search.js
1.25 kB
| import React, {useState} from 'react'; | |
| import './Search.css'; | |
| import "react-date-range/dist/styles.css"; // main style file | |
| import "react-date-range/dist/theme/default.css"; // theme css file | |
| import { DateRangePicker } from "react-date-range"; | |
| import { Button } from "@material-ui/core"; | |
| import PeopleIcon from "@material-ui/icons/People"; | |
| import { useHistory } from "react-router-dom"; | |
| // DATE PICKER COMPONENT | |
| function Search() { | |
| const history = useHistory(); | |
| const [startDate, setStartDate] = useState(new Date()); | |
| const [endDate, setEndDate] = useState(new Date()); | |
| const selectionRange = { | |
| startDate: startDate, | |
| endDate: endDate, | |
| key: "selection", | |
| }; | |
| function handleSelect(ranges) { | |
| setStartDate(ranges.selection.startDate); | |
| setEndDate(ranges.selection.endDate); | |
| } | |
| return ( | |
| <div className='search'> | |
| <DateRangePicker ranges={[selectionRange]} onChange={handleSelect} /> | |
| <h2> | |
| Number of guests <PeopleIcon /> | |
| </h2> | |
| <input min={0} defaultValue={2} type="number" /> | |
| <Button onClick={() => history.push('/search')}>Search Airbnb</Button> | |
| </div> | |
| ) | |
| } | |
| export default Search | |