@@ -8,6 +8,35 @@ import Router from "./Router/Router";
8
8
import PermanentAssets from "./basicElements/PermanentAssets" ;
9
9
10
10
function App ( ) : ReactElement {
11
+ import React , { ReactElement , useEffect , useState } from 'react' ;
12
+ import { connect , ConnectedProps } from 'react-redux'
13
+ import { addAccessToken , addRefreshToken } from "../background/redux/actions/tokens" ;
14
+ import { SystemState } from "../background/redux/actions/sytemState" ;
15
+ import { Button } from "react-bootstrap" ;
16
+
17
+
18
+ // this takes the redux store and maps everything that is needed to the function props
19
+ const mapState = ( state : SystemState ) => ( {
20
+ tokens : { refreshToken : state . tokens . refreshToken , accessToken : state . tokens . accessToken }
21
+ } )
22
+
23
+ // this takes the redux actions and maps them to the props
24
+ const mapDispatch = {
25
+ addRefreshToken, addAccessToken
26
+ }
27
+
28
+ const connector = connect ( mapState , mapDispatch )
29
+
30
+ type PropsFromRedux = ConnectedProps < typeof connector >
31
+
32
+ // this defines the component props and also adds the redux imported props
33
+ type Props = PropsFromRedux & { }
34
+
35
+ function App ( props : Props ) : ReactElement {
36
+
37
+
38
+ console . log ( props . tokens . refreshToken )
39
+ console . log ( props . tokens )
11
40
12
41
13
42
return (
@@ -24,4 +53,4 @@ function App(): ReactElement {
24
53
) ;
25
54
}
26
55
27
- export default App ;
56
+ export default connector ( App ) ;
0 commit comments