1
- import React , { useEffect , useState } from 'react'
1
+ import React , { useEffect } from 'react'
2
2
import ReactDOM from 'react-dom/client'
3
3
import {
4
4
createBrowserRouter ,
@@ -21,9 +21,6 @@ function Root() {
21
21
< Link id = "change-route" to = "/contacts/1" >
22
22
Contact 1
23
23
</ Link >
24
- < Link id = "change-route-nested-component" to = "/nested-component" >
25
- Nested Component
26
- </ Link >
27
24
< Outlet />
28
25
</ >
29
26
)
@@ -37,56 +34,17 @@ function Contact() {
37
34
return < div id = "contact" > Contact</ div >
38
35
}
39
36
40
- function Component ( count ) {
41
- return (
42
- < >
43
- < div >
44
- < p > I am a wrapped component!</ p >
45
- </ div >
46
- < div > { count } </ div >
47
- </ >
48
- )
49
- }
50
-
51
- // const WrappedComponent = withInstrumentedComponent(Component)
52
-
53
- function NestedComponent ( ) {
54
- const [ show , setShow ] = useState ( true )
55
- const [ count , setCount ] = useState ( 0 )
56
-
57
- return (
58
- < div >
59
- < button id = 'update-component' onClick = { ( ) => setCount ( count + 1 ) } >
60
- Increment
61
- </ button >
62
- < button
63
- id = 'unmount-component'
64
- onClick = { ( ) => {
65
- setShow ( ! show )
66
- } }
67
- >
68
- { show ? 'Unmount Component' : 'Mount Component' }
69
- </ button >
70
- { show && < Component count = { count } /> }
71
- </ div >
72
- )
73
- }
74
-
75
37
const routes = [
76
38
{
77
39
path : '/' ,
78
40
element : < Root /> ,
79
41
children : [
80
42
{
81
43
path : 'contacts/:contactId' ,
82
- element : < Contact /> ,
83
- } ,
84
- {
85
- path : 'nested-component' ,
86
- element : < NestedComponent /> ,
87
- } ,
88
- ] ,
89
- } ,
44
+ element : < Contact />
45
+ }
46
+ ]
47
+ }
90
48
]
91
49
92
50
const router = createBrowserRouter ( routes , { basename } )
0 commit comments