Skip to content

Commit 941ad35

Browse files
committed
improve react hygine in contribute details section
1 parent 21f2f94 commit 941ad35

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

src/component/modals/ContributeDetails.jsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState, useEffect } from 'react';
1+
import React, { useState, useEffect, useRef } from 'react';
22
import { toast } from 'react-toastify';
33
import axios from 'axios';
44
import { EXECUTION_ENGINE_URL } from '../../serverCon/config';
@@ -20,15 +20,26 @@ const ContributeDetails = ({ superState, dispatcher }) => {
2020
const [desc, setDesc] = useState('');
2121
const [branch, setBranch] = useState('');
2222
const [showAdvanceOptions, setShowAdvanceOptions] = useState(false);
23+
const prevOpenRef = useRef(false);
2324

2425
useEffect(() => {
25-
if (superState.contributeModal) {
26+
if (superState.contributeModal && !prevOpenRef.current) {
2627
const activeGraph = superState.graphs[superState.curGraphIndex] ?? {};
2728
setStudy(activeGraph.projectName ?? '');
2829
setPath(superState.uploadedDirName ?? '');
2930
setAuth(activeGraph.authorName ?? '');
31+
setTitle('');
32+
setDesc('');
33+
setBranch('');
34+
setShowAdvanceOptions(false);
3035
}
31-
}, [superState.contributeModal]);
36+
prevOpenRef.current = superState.contributeModal;
37+
}, [
38+
superState.contributeModal,
39+
superState.graphs,
40+
superState.curGraphIndex,
41+
superState.uploadedDirName,
42+
]);
3243
const submit = async (e) => {
3344
if (study === '' || path === '' || auth === '') {
3445
toast.info('Please Provide necessary inputs');

0 commit comments

Comments
 (0)