@@ -14,15 +14,17 @@ import {useSelector, useDispatch } from 'react-redux';
14
14
const CreateContainer = ( ) => {
15
15
const defaultTableData = [ { key : 'Enter Key' , value : 'Enter value' } ] ;
16
16
const allContext = useSelector ( state => state . contextSlice ) ;
17
+
17
18
const store = useStore ( ) ;
18
- const [ state , setState ] = useState ( allContext ) ;
19
+ const [ state , setState ] = useState ( [ ] ) ;
19
20
const [ tableState , setTableState ] = React . useState ( defaultTableData ) ;
20
21
const [ contextInput , setContextInput ] = React . useState ( null ) ;
21
22
const [ stateContext , dispatchContext ] = useContext ( StateContext ) ;
22
23
const dispatch = useDispatch ( ) ;
23
24
24
25
//pulling data from redux store
25
26
useEffect ( ( ) => {
27
+ console . log ( 'allcon' , allContext )
26
28
setState ( allContext )
27
29
// setState(store.getState().contextSlice);
28
30
@@ -41,22 +43,22 @@ const CreateContainer = () => {
41
43
setContextInput ( '' ) ;
42
44
dispatch ( addContext ( contextInput ) ) ;
43
45
44
- setState ( allContext ) ;
46
+ // setState(allContext);
45
47
} ;
46
48
47
49
//update data store when user add new key-value pair to context
48
50
const handleClickInputData = ( { name } , { inputKey, inputValue } ) => {
49
51
dispatch (
50
52
addContext ( { name, inputKey, inputValue } )
51
53
) ;
52
- setState ( allContext ) ;
54
+ // setState(allContext);
53
55
} ;
54
56
55
57
//update data store when user deletes context
56
58
const handleDeleteContextClick = ( ) => {
57
59
dispatch ( deleteContext ( contextInput ) ) ;
58
60
setContextInput ( '' ) ;
59
- setState ( allContext ) ;
61
+ // setState(allContext);
60
62
setTableState ( defaultTableData ) ;
61
63
dispatchContext ( {
62
64
type : 'DELETE ELEMENT' ,
0 commit comments