Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. // src/screens/home/containers/Search.js
  2. import React from 'react';
  3. import { connect } from 'react-redux'
  4. import Form from 'react-bootstrap/Form'
  5. import { getBooks } from '../actions'
  6.  
  7. const Search = ({query, onInputChange}) => {
  8. const handleOnSubmit = (e) => {
  9. e.preventDefault();
  10. }
  11. return (
  12. <div className="search-books">
  13. <Form className="search-books--form" onSubmit={handleOnSubmit}>
  14. <Form.Group>
  15. <Form.Control
  16. type="text"
  17. placeholder="Harry Potter, Food and Love"
  18. onChange={(e) => onInputChange(e.target.value)}
  19. value={query}
  20. />
  21. <Form.Text className="text-muted">
  22. Search the world's most comprehensive index of full-text books.
  23. </Form.Text>
  24. </Form.Group>
  25. </Form>
  26. </div>
  27. )
  28. }
  29.  
  30. const mapStateToProps = state => ({
  31. query: state.books.query
  32. })
  33. const mapDispatchToProps = dispatch => ({
  34. onInputChange = (query) => dispatch(getBooks(query))
  35. })
  36.  
  37. export default connect(
  38. mapStateToProps,
  39. mapDispatchToProps
  40. )(Search);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement