Skip to content

Commit 32ccadf

Browse files
committed
Edit Button Fix
1 parent 34c13b1 commit 32ccadf

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/App.jsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff 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(() => {

src/components/Sidebar/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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>

0 commit comments

Comments
 (0)