Skip to content

Commit 85ef1ec

Browse files
committed
fixes more context slice bugs
1 parent 8cb6fb2 commit 85ef1ec

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

app/src/components/ContextAPIManager/AssignTab/AssignContainer.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const AssignContainer = () => {
2828
//fetching data from redux store
2929
useEffect(() => {
3030
setState(allContext);
31-
}, []);
31+
}, [allContext]);
3232

3333
const renderTable = targetContext => {
3434
if (targetContext === null || !targetContext.values) {
@@ -78,7 +78,7 @@ const AssignContainer = () => {
7878
payload: 'FAKE_ID'
7979
});
8080

81-
setState(allContext);
81+
// setState(allContext);
8282
renderComponentTable(componentInput);
8383
};
8484

app/src/components/ContextAPIManager/CreateTab/CreateContainer.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,17 @@ import {useSelector, useDispatch } from 'react-redux';
1414
const CreateContainer = () => {
1515
const defaultTableData = [{ key: 'Enter Key', value: 'Enter value' }];
1616
const allContext = useSelector(state => state.contextSlice);
17+
1718
const store = useStore();
18-
const [state, setState] = useState(allContext);
19+
const [state, setState] = useState([]);
1920
const [tableState, setTableState] = React.useState(defaultTableData);
2021
const [contextInput, setContextInput] = React.useState(null);
2122
const [stateContext, dispatchContext] = useContext(StateContext);
2223
const dispatch = useDispatch();
2324

2425
//pulling data from redux store
2526
useEffect(() => {
27+
console.log('allcon',allContext)
2628
setState(allContext)
2729
// setState(store.getState().contextSlice);
2830

@@ -41,22 +43,22 @@ const CreateContainer = () => {
4143
setContextInput('');
4244
dispatch(addContext(contextInput));
4345

44-
setState(allContext);
46+
// setState(allContext);
4547
};
4648

4749
//update data store when user add new key-value pair to context
4850
const handleClickInputData = ({ name }, { inputKey, inputValue }) => {
4951
dispatch(
5052
addContext({ name, inputKey, inputValue })
5153
);
52-
setState(allContext);
54+
// setState(allContext);
5355
};
5456

5557
//update data store when user deletes context
5658
const handleDeleteContextClick = () => {
5759
dispatch(deleteContext(contextInput));
5860
setContextInput('');
59-
setState(allContext);
61+
// setState(allContext);
6062
setTableState(defaultTableData);
6163
dispatchContext({
6264
type: 'DELETE ELEMENT',

0 commit comments

Comments
 (0)