File tree Expand file tree Collapse file tree 3 files changed +24
-11
lines changed Expand file tree Collapse file tree 3 files changed +24
-11
lines changed Original file line number Diff line number Diff line change @@ -6,26 +6,34 @@ import Footer from "./components/Footer";
6
6
import { BrowserRouter as Router , Routes , Route } from "react-router-dom" ;
7
7
import Place from "./components/Place" ;
8
8
import Modal from "./components/Modal" ;
9
+ import { createContext } from "react" ;
10
+
11
+ export const thetruecontext = createContext ( ) ;
9
12
10
13
function App ( ) {
11
-
12
14
const [ showModal , setshowModal ] = useState ( false ) ;
13
15
14
-
16
+ const trueboolean = function funcTrue ( ) {
17
+ setshowModal ( true ) ;
18
+ } ;
15
19
return (
16
20
< Router >
17
21
< >
18
-
19
- < Modal modalState = { showModal } setshowModalFalse = { ( ) => setshowModal ( false ) } />
20
- < Nav setshowModalTrue = { ( ) => setshowModal ( true ) } />
22
+ < Modal
23
+ modalState = { showModal }
24
+ setshowModalFalse = { ( ) => setshowModal ( false ) }
25
+ />
26
+ < thetruecontext . Provider value = { trueboolean } >
27
+ < Nav />
28
+ </ thetruecontext . Provider >
29
+
21
30
< Routes >
22
31
< Route path = "/" element = { < Homepage /> } />
23
32
24
33
< Route path = "/place" element = { < Place /> } />
25
34
</ Routes >
26
35
< Footer />
27
-
28
- </ >
36
+ </ >
29
37
</ Router >
30
38
) ;
31
39
}
Original file line number Diff line number Diff line change @@ -9,7 +9,9 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
9
9
import { Link } from 'react-router-dom' ;
10
10
11
11
12
- function Nav ( { setshowModalTrue} ) {
12
+
13
+ function Nav ( ) {
14
+
13
15
14
16
return (
15
17
< section className = "nav--container grid" >
@@ -28,7 +30,7 @@ function Nav({setshowModalTrue}) {
28
30
</ nav >
29
31
< div >
30
32
{ " " }
31
- < Button name = "Connect wallet" styleclass = "nav-btn" clicked = { setshowModalTrue } />
33
+ < Button name = "Connect wallet" styleclass = "nav-btn" />
32
34
</ div >
33
35
< div className = "hamburger-menu" >
34
36
< FontAwesomeIcon icon = { faBars } className = "hamburger-menu" />
Original file line number Diff line number Diff line change 1
1
import React from "react" ;
2
2
import "../styles/button.css" ;
3
+ import { thetruecontext } from '../App' ;
4
+ import { useContext } from "react" ;
3
5
4
- function Button ( { name, styleclass, clicked } ) {
5
- return < button onClick = { clicked } className = { `btn ${ styleclass } ` } > { name } </ button > ;
6
+ function Button ( { name, styleclass} ) {
7
+ const settoTrue = useContext ( thetruecontext ) ;
8
+ return < button onClick = { settoTrue } className = { `btn ${ styleclass } ` } > { name } </ button > ;
6
9
}
7
10
8
11
export default Button ;
You can’t perform that action at this time.
0 commit comments