style: add eslint configuration and fixed linter issues (#35)
* style: add eslint configuration as per bee-js * chore: add `plugin:react/reocommended` in `.eslintrc` Co-authored-by: nugaon <50576770+nugaon@users.noreply.github.com> * chore: add `consistent` to `array-bracket-newline` as per review * style: after automatic fixes with `npm run lint` * style: fixed all linter errors * refactor: fixed all linter warnings * chore: added missing new line at end of `.prettierrc` file Co-authored-by: nugaon <50576770+nugaon@users.noreply.github.com>
This commit is contained in:
+18
-18
@@ -1,18 +1,18 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { BrowserRouter as Router } from 'react-router-dom';
|
||||
import './App.css';
|
||||
import { ReactElement, useEffect, useState } from 'react'
|
||||
import { BrowserRouter as Router } from 'react-router-dom'
|
||||
import './App.css'
|
||||
|
||||
import { ThemeProvider } from '@material-ui/styles';
|
||||
import CssBaseline from '@material-ui/core/CssBaseline';
|
||||
import { ThemeProvider } from '@material-ui/styles'
|
||||
import CssBaseline from '@material-ui/core/CssBaseline'
|
||||
|
||||
import BaseRouter from './routes/routes';
|
||||
import { lightTheme, darkTheme } from './theme';
|
||||
import BaseRouter from './routes/routes'
|
||||
import { lightTheme, darkTheme } from './theme'
|
||||
|
||||
function App() {
|
||||
const [themeMode, toggleThemeMode] = useState('light');
|
||||
const App = (): ReactElement => {
|
||||
const [themeMode, toggleThemeMode] = useState('light')
|
||||
|
||||
useEffect(() => {
|
||||
let theme = localStorage.getItem('theme')
|
||||
const theme = localStorage.getItem('theme')
|
||||
|
||||
if (theme) {
|
||||
toggleThemeMode(String(localStorage.getItem('theme')))
|
||||
@@ -21,14 +21,14 @@ function App() {
|
||||
}
|
||||
|
||||
window?.matchMedia('(prefers-color-scheme: dark)')?.addEventListener('change', e => {
|
||||
toggleThemeMode(e?.matches ? "dark" : "light")
|
||||
});
|
||||
|
||||
return () => window?.matchMedia('(prefers-color-scheme: dark)')?.removeEventListener('change', e => {
|
||||
toggleThemeMode(e?.matches ? "dark" : "light")
|
||||
toggleThemeMode(e?.matches ? 'dark' : 'light')
|
||||
})
|
||||
|
||||
}, []);
|
||||
return () =>
|
||||
window?.matchMedia('(prefers-color-scheme: dark)')?.removeEventListener('change', e => {
|
||||
toggleThemeMode(e?.matches ? 'dark' : 'light')
|
||||
})
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<div className="App">
|
||||
@@ -39,7 +39,7 @@ function App() {
|
||||
</Router>
|
||||
</ThemeProvider>
|
||||
</div>
|
||||
);
|
||||
)
|
||||
}
|
||||
|
||||
export default App;
|
||||
export default App
|
||||
|
||||
Reference in New Issue
Block a user