8000 updated rescountries project · devvsakib/frontendmentor.io@f00bdc9 · GitHub
[go: up one dir, main page]

Skip to content

Commit f00bdc9

Browse files
committed
updated rescountries project
1 parent 5898620 commit f00bdc9

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

rest-countries-api/src/App.jsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
11
import './App.css'
2-
import { useState } from 'react'
2+
import { useState, useEffect } from 'react'
33
import { Routes, Route } from 'react-router-dom'
44
import Header from './component/Header/Header'
55
import Home from './pages/Home';
66
import Details from './pages/Details';
77

88
function App() {
9-
const [theme, setTheme] = useState(false);
9+
const [theme, setTheme] = useState(false)
10+
let themes;
11+
if (localStorage) {
12+
themes = localStorage.getItem("theme")
13+
}
14+
if (theme == 'true') {
15+
document.body.classList.add("dark")
16+
} else {
17+
document.body.classList.remove("dark")
18+
}
19+
1020
const darkMode = () => {
11-
document.body.classList.toggle('dark');
1221
setTheme(!theme)
22+
localStorage.setItem("theme", theme)
1323
}
1424
return (
1525
<div className="App dark:text-white text-[#111517]">

0 commit comments

Comments
 (0)
0