Skip to content

Commit de88148

Browse files
committed
fix react hook error
1 parent bab93e8 commit de88148

1 file changed

Lines changed: 8 additions & 16 deletions

File tree

platforms/web/src/Learn.tsx

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,7 @@ function Learn() {
1818
const updateTimeoutRef = useRef<number | null>(null);
1919

2020
// Extract json ID from hash
21-
const getJsonIdFromHash = () => {
22-
const hash = location.hash;
23-
if (hash.startsWith('#json=')) {
24-
return hash.replace('#json=', '');
25-
}
26-
return null;
27-
};
28-
29-
const jsonId = getJsonIdFromHash();
21+
const jsonId = location.hash.startsWith('#json=') ? location.hash.replace('#json=', '') : null;
3022

3123
// Load roadmap data from jsonStore if needed
3224
useEffect(() => {
@@ -141,6 +133,13 @@ function Learn() {
141133
}
142134
}, []);
143135

136+
// Load all maps for the list view
137+
useEffect(() => {
138+
if (!jsonId) {
139+
db.getAllLearningMaps().then(setAllMaps);
140+
}
141+
}, [jsonId]);
142+
144143
const handleAddMap = () => {
145144
// Parse URL to extract json ID
146145
const urlMatch = newMapUrl.match(/#json=([^&]+)/);
@@ -268,13 +267,6 @@ function Learn() {
268267
);
269268
}
270269

271-
// Load all maps for the list view
272-
useEffect(() => {
273-
if (!jsonId) {
274-
db.getAllLearningMaps().then(setAllMaps);
275-
}
276-
}, [jsonId]);
277-
278270
return (
279271
<div className="learn-list-container">
280272
<div className="learn-toolbar">

0 commit comments

Comments
 (0)