aboutsummaryrefslogtreecommitdiff
path: root/src/components/Fab
diff options
context:
space:
mode:
authoreug-vs <eug-vs@keemail.me>2020-10-07 23:25:52 +0300
committereug-vs <eug-vs@keemail.me>2020-10-07 23:25:52 +0300
commit4471fef74dfe312a8cf6a1440f5a703e897af136 (patch)
treeafbd8d0f565f7c270c7c63e4765d8810c30af890 /src/components/Fab
parentc3f9271adebf37ed66664d978cfae2a6b327ebff (diff)
downloadwhich-ui-4471fef74dfe312a8cf6a1440f5a703e897af136.tar.gz
feat: wire modal routes
Diffstat (limited to 'src/components/Fab')
-rw-r--r--src/components/Fab/Fab.tsx23
1 files changed, 10 insertions, 13 deletions
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>
);
};