Skip to content

Commit d0b67e6

Browse files
committed
dropzone not sending propopsal id to attach new image when proposal is newly saved
1 parent 47108d9 commit d0b67e6

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/user/proposals/ProposalEditor/EditorContent/DropZone.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useMemo, useCallback, useState } from "react";
1+
import React, { useMemo, useCallback, useState, useEffect } from "react";
22
import { useDropzone } from "react-dropzone";
33
import { toast, ToastContainer } from "react-toastify";
44
import "react-toastify/dist/ReactToastify.css";
@@ -33,7 +33,11 @@ const rejectStyle = {
3333
};
3434

3535
function StyledDropzone(props) {
36-
const [proposalId, setProposalId] = useState(props.idContent);
36+
const [proposalId, setProposalId] = useState(null);
37+
38+
useEffect(() => {
39+
setProposalId(props.idContent)
40+
}, [props.idContent])
3741

3842
const onDrop = useCallback((acceptedFiles) => {
3943
let formData = new FormData();
@@ -53,7 +57,7 @@ function StyledDropzone(props) {
5357
.catch((err) => {
5458
console.log(err);
5559
});
56-
}, []);
60+
}, [proposalId]);
5761

5862
const {
5963
getRootProps,

src/user/proposals/ProposalEditor/EditorContent/EditorContent.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ class EditorContent extends Component {
268268
<div>
269269
{!this.state.newProposal ? (
270270
<StyledDropzone
271-
idContent={this.props.location.state.proposalId}
271+
idContent={this.state.proposalId}
272272
/>
273273
) : (
274274
<div></div>

0 commit comments

Comments
 (0)