Advertisement
Guest User

NewBlog.js

a guest
Nov 18th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React from "react"
  2. import PropTypes from "prop-types"
  3.  
  4. import Typography from "@material-ui/core/Typography"
  5. import Button from "@material-ui/core/Button"
  6. import { makeStyles } from "@material-ui/core/styles"
  7.  
  8. const useStyles = makeStyles(theme => ({
  9.   button: {
  10.     margin: theme.spacing(1),
  11.   },
  12.   input: {
  13.     display: "none",
  14.   },
  15. }))
  16.  
  17. const NewBlog = ({ author, title, url, addBlog, newBlogRef }) => {
  18.   const classes = useStyles()
  19.  
  20.   return (
  21.     <div>
  22.       <Typography variant="h4" gutterBottom>
  23.         {" "}
  24.         Create New Blog{" "}
  25.       </Typography>
  26.  
  27.       <form onSubmit={addBlog} ref={newBlogRef}>
  28.         <Typography gutterBottom>
  29.           <div>
  30.             Title:
  31.             <input id="title" {...title} reset={null} />
  32.           </div>
  33.           <div>
  34.             Author:
  35.             <input id="author" {...author} reset={null} />
  36.           </div>
  37.           <div>
  38.             URL:
  39.             <input id="url" {...url} reset={null} />
  40.           </div>
  41.           <Button
  42.             variant="contained"
  43.             color="primary"
  44.             size="small"
  45.             className={classes.button}
  46.             type="submit"
  47.             data-cy="createblog"
  48.           >
  49.             Create
  50.           </Button>
  51.         </Typography>
  52.       </form>
  53.     </div>
  54.   )
  55. }
  56.  
  57. NewBlog.propTypes = {
  58.   addBlog: PropTypes.func.isRequired,
  59. }
  60.  
  61. export default NewBlog
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement