Skip to content

Commit a026349

Browse files
committed
Sync options modal form with persisted state on open
1 parent 5b79fb7 commit a026349

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

src/component/modals/OptionsModal.jsx

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState } from 'react';
1+
import React, { useEffect, useState } from 'react';
22
import ParentModal from './ParentModal';
33
import { actionType as T } from '../../reducer';
44
import './optionsModal.css';
@@ -10,6 +10,25 @@ const OptionsModal = ({ superState, dispatcher }) => {
1010
const [param, setParam] = useState('');
1111
const [maxT, setmaxT] = useState('');
1212
const [library, setLibrary] = useState('');
13+
14+
useEffect(() => {
15+
if (!superState.optionsModal) return;
16+
setUnlock(Boolean(superState.unlockCheck));
17+
setDocker(Boolean(superState.dockerCheck));
18+
setOctave(Boolean(superState.octave));
19+
setParam(superState.params || '');
20+
setmaxT(superState.maxTime || '');
21+
setLibrary(superState.library || '');
22+
}, [
23+
superState.optionsModal,
24+
superState.unlockCheck,
25+
superState.dockerCheck,
26+
superState.octave,
27+
superState.params,
28+
superState.maxTime,
29+
superState.library,
30+
]);
31+
1332
const close = () => {
1433
dispatcher({ type: T.SET_OPTIONS_MODAL, payload: false });
1534
dispatcher(

0 commit comments

Comments
 (0)