Skip to content

Commit f0304a6

Browse files
fix: navigation on mobile
1 parent 4ba623f commit f0304a6

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

custom-implementation/src/main.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,19 @@ const render = async () => {
1717
*/
1818

1919
const data = await getPageData()
20-
const sidenav = document.querySelector('button.fern-search-bar')
21-
?.parentElement as HTMLElement
2220

2321
const theme = document.getElementsByTagName('html')[0].getAttribute('class')
2422

23+
const sidenav = document.querySelector('button.fern-search-bar')
24+
?.parentElement as HTMLElement
25+
2526
if (!document.getElementById('theme-switch')) {
2627
const wrapper = document.createElement('div')
2728
wrapper.setAttribute('id', 'theme-switch')
28-
sidenav.appendChild(wrapper)
29-
ReactDOM.render(React.createElement(ThemeSwitch), wrapper)
29+
if (sidenav) {
30+
sidenav.appendChild(wrapper)
31+
ReactDOM.render(React.createElement(ThemeSwitch), wrapper)
32+
}
3033
}
3134

3235
ReactDOM.render(

0 commit comments

Comments
 (0)