From 28c80d1c2e33706a3a754b3e5e26dc2685cf8592 Mon Sep 17 00:00:00 2001 From: ilyayudovin <ilyayudovin123@gmail.com> Date: Sun, 28 Jun 2020 19:32:48 +0300 Subject: fix: able to add 2 different images to poll submission --- src/pages/FeedPage/PollSubmissionImage.tsx | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'src/pages/FeedPage/PollSubmissionImage.tsx') diff --git a/src/pages/FeedPage/PollSubmissionImage.tsx b/src/pages/FeedPage/PollSubmissionImage.tsx index c7e638c..bf268a3 100644 --- a/src/pages/FeedPage/PollSubmissionImage.tsx +++ b/src/pages/FeedPage/PollSubmissionImage.tsx @@ -6,6 +6,7 @@ import UploadImage from '../../components/UploadImage/UploadImage'; import { Contents } from './types'; interface PropTypes { + contents: Contents; setContents: (a: Contents) => void; which: 'left' | 'right'; } @@ -21,7 +22,7 @@ const useStyles = makeStyles(theme => ({ } })); -const PollSubmissionImage: React.FC<PropTypes> = ({ setContents, which }) => { +const PollSubmissionImage: React.FC<PropTypes> = ({ setContents, which, contents }) => { const classes = useStyles(); const [display, setDisplay] = useState(false); const [image, setImage] = useState(''); @@ -32,16 +33,8 @@ const PollSubmissionImage: React.FC<PropTypes> = ({ setContents, which }) => { const patchUrl = (url: string) => { setImage(url); - let nextImage; - which === 'left' ? nextImage = 'right' : nextImage = 'left'; - setContents({ - [which]: { - url - }, - [nextImage]: { - url - } - }); + contents[which] = {url}; + setContents({...contents}); }; -- cgit v1.2.3