From 4471fef74dfe312a8cf6a1440f5a703e897af136 Mon Sep 17 00:00:00 2001
From: eug-vs <eug-vs@keemail.me>
Date: Wed, 7 Oct 2020 23:25:52 +0300
Subject: feat: wire modal routes

---
 src/components/Fab/Fab.tsx | 23 ++++++++++-------------
 1 file changed, 10 insertions(+), 13 deletions(-)

(limited to 'src/components/Fab/Fab.tsx')

diff --git a/src/components/Fab/Fab.tsx b/src/components/Fab/Fab.tsx
index 7ca2893..f6b85e5 100644
--- a/src/components/Fab/Fab.tsx
+++ b/src/components/Fab/Fab.tsx
@@ -1,5 +1,5 @@
 import React from 'react';
-import { useHistory } from 'react-router-dom';
+import { useLocation, Link } from 'react-router-dom';
 import { Fab as FabBase, Slide, useScrollTrigger } from '@material-ui/core/';
 import { makeStyles } from '@material-ui/core/styles';
 import PlusIcon from '@material-ui/icons/Add';
@@ -26,22 +26,19 @@ const useStyles = makeStyles(theme => ({
 
 const Fab: React.FC<PropTypes> = ({ hideOnScroll = false }) => {
   const classes = useStyles();
-  const history = useHistory();
+  const location = useLocation();
   const trigger = useScrollTrigger();
 
-  const handleClick = () => {
-    history.push('/new');
-  };
-
   return (
     <Slide appear={false} direction="up" in={(!hideOnScroll) || !trigger}>
-      <FabBase
-        onClick={handleClick}
-        className={classes.root}
-        color="secondary"
-      >
-        <PlusIcon />
-      </FabBase>
+      <Link to={{ pathname: '/new', state: { background: location } }}>
+        <FabBase
+          className={classes.root}
+          color="secondary"
+        >
+          <PlusIcon />
+        </FabBase>
+      </Link>
     </Slide>
   );
 };
-- 
cgit v1.2.3

