File tree Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -18,20 +18,22 @@ export function App() {
1818
1919 const { getTopics, getContent } = useApi ( ) ;
2020
21- const switchContent = useCallback ( ( url ) => {
21+ const switchContent = useCallback ( ( item ) => {
2222 setLoading ( true ) ;
2323 setContent ( null ) ;
24- getContent ( url , ( content ) => {
24+ getContent ( item . url , ( content ) => {
25+ setEditUrl ( remoteUrl ( item . path ) ) ;
2526 setContent ( content ) ;
2627 setLoading ( false ) ;
2728 } ) ;
2829 } , [ getContent ] ) ;
2930
3031 const fetchSidebarData = useCallback ( async ( ) => {
3132 const topics = await getTopics ( ) ;
33+ const firstTopic = topics ?. [ 0 ] . items ?. [ 0 ] ;
34+
3235 setSidebar ( topics ) ;
33- setEditUrl ( remoteUrl ( topics ?. [ 0 ] . items ?. [ 0 ] . path ) ) ;
34- switchContent ( topics ?. [ 0 ] . items ?. [ 0 ] . url ) ;
36+ switchContent ( firstTopic ) ;
3537 } , [ getTopics , switchContent ] ) ;
3638
3739 useEffect ( ( ) => {
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ export function Sidebar({ contents, switchContent }) {
2020 key = { item . value }
2121 label = { item . label }
2222 value = { item . value }
23- action = { ( ) => switchContent ( item . url ) }
23+ action = { ( ) => switchContent ( item ) }
2424 /> )
2525 }
2626 </ div >
You can’t perform that action at this time.
0 commit comments