diff --git a/src/App.tsx b/src/App.tsx
index 6b2113b..e88625d 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -1,4 +1,4 @@
-import * as React from 'react'
+import { Suspense, lazy, useState } from 'react'
import styled from '@emotion/styled'
@@ -12,8 +12,8 @@ import SettingsProvider from './context/SettingsProvider'
import Wrapper from './Wrapper'
-const Weather = React.lazy(() => import('./components/Weather'))
-const Preferences = React.lazy(() => import('./components/Preferences'))
+const Weather = lazy(() => import('./components/Weather'))
+const Preferences = lazy(() => import('./components/Preferences'))
const Layout = styled.div`
position: relative;
@@ -26,8 +26,8 @@ const Main = styled.div<{ menuOpen: boolean }>`
display: ${props => (props.menuOpen ? 'none' : 'block')};
`
-const App = (): JSX.Element => {
- const [menuOpen, setMenuOpen] = React.useState(false)
+const App = () => {
+ const [menuOpen, setMenuOpen] = useState(false)
return (
@@ -36,16 +36,16 @@ const App = (): JSX.Element => {
- }>
+ }>
-
+
- }>
+ }>
-
+
diff --git a/src/Wrapper.tsx b/src/Wrapper.tsx
index 7b9b1b8..7813479 100644
--- a/src/Wrapper.tsx
+++ b/src/Wrapper.tsx
@@ -1,4 +1,5 @@
-import * as React from 'react'
+import type { ReactNode } from 'react'
+import { useContext } from 'react'
import { Global, ThemeProvider } from '@emotion/react'
@@ -11,11 +12,11 @@ import { globalStyles } from './theme'
const matchMediaFallback = (): boolean =>
window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches
-const Wrapper = ({ children }: { children: React.ReactNode }): JSX.Element => {
+const Wrapper = ({ children }: { children: ReactNode }) => {
const {
settings: { prefersDarkMode = matchMediaFallback() },
setSetting,
- } = React.useContext(SettingsContext)
+ } = useContext(SettingsContext)
const theme = useTheme()
diff --git a/src/components/Bookmark.tsx b/src/components/Bookmark.tsx
index 8a9e585..aa43747 100644
--- a/src/components/Bookmark.tsx
+++ b/src/components/Bookmark.tsx
@@ -1,4 +1,4 @@
-import * as React from 'react'
+import { useContext, useState } from 'react'
import styled from '@emotion/styled'
import { faLink } from '@fortawesome/free-solid-svg-icons'
@@ -45,11 +45,11 @@ type Props = {
bookmark: BookmarkLink
}
-const Bookmark = ({ bookmark }: Props): JSX.Element => {
- const [error, setError] = React.useState(false)
+const Bookmark = ({ bookmark }: Props) => {
+ const [error, setError] = useState(false)
const {
settings: { showFavicons = true },
- } = React.useContext(SettingsContext)
+ } = useContext(SettingsContext)
return (
diff --git a/src/components/Menu.tsx b/src/components/Menu.tsx
index 7db3c00..bb93b39 100644
--- a/src/components/Menu.tsx
+++ b/src/components/Menu.tsx
@@ -25,7 +25,7 @@ const Menu = ({
}: {
menuOpen: boolean
onClick: () => void
-}): JSX.Element => (
+}) => (
diff --git a/src/components/Preferences/BackupRestore.tsx b/src/components/Preferences/BackupRestore.tsx
index da77c94..d1a18bb 100644
--- a/src/components/Preferences/BackupRestore.tsx
+++ b/src/components/Preferences/BackupRestore.tsx
@@ -1,4 +1,5 @@
-import * as React from 'react'
+import type { ChangeEvent } from 'react'
+import { useContext } from 'react'
import { setMany, clear } from 'idb-keyval'
@@ -27,10 +28,10 @@ const Style = styled.div`
}
`
-const BackupRestore = (): JSX.Element => {
- const { settings, setSettings, store } = React.useContext(SettingsContext)
+const BackupRestore = () => {
+ const { settings, setSettings, store } = useContext(SettingsContext)
- const onChange = async (event: React.ChangeEvent) => {
+ const onChange = async (event: ChangeEvent) => {
if (event.target.files) {
const newSettings = (await readJsonFile(
event.target.files[0]
diff --git a/src/components/Preferences/BookmarkRow.tsx b/src/components/Preferences/BookmarkRow.tsx
index 1ce6c1e..85d84c8 100644
--- a/src/components/Preferences/BookmarkRow.tsx
+++ b/src/components/Preferences/BookmarkRow.tsx
@@ -1,10 +1,10 @@
-import * as React from 'react'
+import { useEffect, type KeyboardEvent, useState, useContext } from 'react'
import axios from 'axios'
import styled from '@emotion/styled'
-import type { BookmarkLink, BookmarkLinks } from '../../types'
+import type { BookmarkLink } from '../../types'
import { SettingsContext } from '../../context/SettingsProvider'
@@ -38,16 +38,16 @@ type Props = {
bookmark?: BookmarkLink
}
-const BookmarkRow = ({ bookmark }: Props): JSX.Element => {
- const [label, setLabel] = React.useState(bookmark?.label ?? '')
- const [url, setUrl] = React.useState(bookmark?.url ?? '')
- const [category, setCategory] = React.useState(bookmark?.category ?? '')
- const [mode, setMode] = React.useState('remove')
+const BookmarkRow = ({ bookmark }: Props) => {
+ const [label, setLabel] = useState(bookmark?.label ?? '')
+ const [url, setUrl] = useState(bookmark?.url ?? '')
+ const [category, setCategory] = useState(bookmark?.category ?? '')
+ const [mode, setMode] = useState('remove')
const {
settings: { bookmarks },
setSetting,
- } = React.useContext(SettingsContext)
+ } = useContext(SettingsContext)
const isExists = () => !!bookmarks?.find((f: BookmarkLink) => f.url === url)
@@ -79,7 +79,7 @@ const BookmarkRow = ({ bookmark }: Props): JSX.Element => {
const newBookmark = { id: Date.now(), label, url, icon, category }
if (bookmarks !== undefined) {
- setSetting('bookmarks', [...bookmarks, newBookmark])
+ setSetting('bookmarks', [...bookmarks, newBookmark])
} else {
setSetting('bookmarks', [newBookmark])
}
@@ -113,7 +113,7 @@ const BookmarkRow = ({ bookmark }: Props): JSX.Element => {
setMode('remove')
}
- const onEnter = (e: React.KeyboardEvent) => {
+ const onEnter = (e: KeyboardEvent) => {
if (e.key === 'Enter') {
switch (mode) {
case 'update':
@@ -129,7 +129,7 @@ const BookmarkRow = ({ bookmark }: Props): JSX.Element => {
}
}
- React.useEffect(() => {
+ useEffect(() => {
const determineMode = () => {
if (!bookmark) {
setMode('add')
diff --git a/src/components/Preferences/Bookmarks.tsx b/src/components/Preferences/Bookmarks.tsx
index eecb523..dacca43 100644
--- a/src/components/Preferences/Bookmarks.tsx
+++ b/src/components/Preferences/Bookmarks.tsx
@@ -1,4 +1,4 @@
-import * as React from 'react'
+import { useContext } from 'react'
import type { BookmarkLink } from '../../types'
@@ -6,10 +6,10 @@ import { SettingsContext } from '../../context/SettingsProvider'
import BookmarkRow from './BookmarkRow'
-const Bookmarks = (): JSX.Element => {
+const Bookmarks = () => {
const {
settings: { bookmarks },
- } = React.useContext(SettingsContext)
+ } = useContext(SettingsContext)
return (
<>
diff --git a/src/components/Preferences/Button.tsx b/src/components/Preferences/Button.tsx
index 8ae397f..6c6d36c 100644
--- a/src/components/Preferences/Button.tsx
+++ b/src/components/Preferences/Button.tsx
@@ -1,4 +1,5 @@
-import * as React from 'react'
+import type { MouseEvent } from 'react'
+import { useContext, useEffect, useState } from 'react'
import styled from '@emotion/styled'
import { faSpinner } from '@fortawesome/free-solid-svg-icons'
@@ -47,7 +48,7 @@ const Style = styled.button<{ isDisabled?: boolean }>`
`
type Props = {
- onClick?: (e: React.MouseEvent) => void
+ onClick?: (e: MouseEvent) => void
disabled?: boolean
className?: 'warning' | 'danger' | 'success'
children: string
@@ -60,11 +61,11 @@ const Button = ({
className,
children,
setClick = true,
-}: Props): JSX.Element => {
- const [clicked, setClicked] = React.useState(false)
- const { settings } = React.useContext(SettingsContext)
+}: Props) => {
+ const [clicked, setClicked] = useState(false)
+ const { settings } = useContext(SettingsContext)
- React.useEffect(() => {
+ useEffect(() => {
setClicked(false)
}, [settings])
diff --git a/src/components/Preferences/Name.tsx b/src/components/Preferences/Name.tsx
index ab6aa62..702aa61 100644
--- a/src/components/Preferences/Name.tsx
+++ b/src/components/Preferences/Name.tsx
@@ -1,20 +1,20 @@
-import * as React from 'react'
+import { useContext } from 'react'
import { SettingsContext } from '../../context/SettingsProvider'
import TextInput from './TextInput'
-const Name = (): JSX.Element => {
+const Name = () => {
const {
settings: { name },
setSetting,
- } = React.useContext(SettingsContext)
+ } = useContext(SettingsContext)
return (
<>
setSetting('name', e.target.value)}
/>
diff --git a/src/components/Preferences/QuickSettings.tsx b/src/components/Preferences/QuickSettings.tsx
index 79d838c..47834db 100644
--- a/src/components/Preferences/QuickSettings.tsx
+++ b/src/components/Preferences/QuickSettings.tsx
@@ -1,4 +1,4 @@
-import * as React from 'react'
+import { useContext } from 'react'
import styled from '@emotion/styled'
@@ -10,11 +10,11 @@ const Style = styled.div`
grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
`
-const QuickSettings = (): JSX.Element => {
+const QuickSettings = () => {
const {
settings: { weather = false, showFavicons = true },
setSetting,
- } = React.useContext(SettingsContext)
+ } = useContext(SettingsContext)
return (