mirror of
https://git.unlock-music.dev/um/um-react.git
synced 2024-11-23 22:02:19 +00:00
refactor: move components to sub dir
This commit is contained in:
parent
b136bac9b6
commit
897830cd44
@ -1,24 +0,0 @@
|
|||||||
import React, { useEffect } from 'react';
|
|
||||||
import App from './App';
|
|
||||||
|
|
||||||
import { ChakraProvider } from '@chakra-ui/react';
|
|
||||||
import { Provider } from 'react-redux';
|
|
||||||
import { theme } from './theme';
|
|
||||||
import { persistSettings } from './features/settings/persistSettings';
|
|
||||||
import type { AppStore } from './store';
|
|
||||||
|
|
||||||
export function Loader({ store }: { store: AppStore }) {
|
|
||||||
useEffect(() => {
|
|
||||||
return persistSettings(store);
|
|
||||||
}, [store]);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<React.StrictMode>
|
|
||||||
<ChakraProvider theme={theme}>
|
|
||||||
<Provider store={store}>
|
|
||||||
<App />
|
|
||||||
</Provider>
|
|
||||||
</ChakraProvider>
|
|
||||||
</React.StrictMode>
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,7 +1,7 @@
|
|||||||
import { Box, Center, Container } from '@chakra-ui/react';
|
import { Box, Center, Container } from '@chakra-ui/react';
|
||||||
import { SelectFile } from './SelectFile';
|
import { SelectFile } from './SelectFile';
|
||||||
|
|
||||||
import { FileListing } from './features/file-listing/FileListing';
|
import { FileListing } from '~/features/file-listing/FileListing';
|
||||||
import { Footer } from './Footer';
|
import { Footer } from './Footer';
|
||||||
|
|
||||||
function App() {
|
function App() {
|
23
src/components/AppRoot.tsx
Normal file
23
src/components/AppRoot.tsx
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
import { useEffect } from 'react';
|
||||||
|
import App from './App';
|
||||||
|
|
||||||
|
import { ChakraProvider } from '@chakra-ui/react';
|
||||||
|
import { Provider } from 'react-redux';
|
||||||
|
import { theme } from '~/theme';
|
||||||
|
import { persistSettings } from '~/features/settings/persistSettings';
|
||||||
|
import { setupStore } from '~/store';
|
||||||
|
|
||||||
|
// Private to this file only.
|
||||||
|
const store = setupStore();
|
||||||
|
|
||||||
|
export function AppRoot() {
|
||||||
|
useEffect(() => persistSettings(store), []);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ChakraProvider theme={theme}>
|
||||||
|
<Provider store={store}>
|
||||||
|
<App />
|
||||||
|
</Provider>
|
||||||
|
</ChakraProvider>
|
||||||
|
);
|
||||||
|
}
|
@ -2,8 +2,8 @@ import { useDropzone } from 'react-dropzone';
|
|||||||
import { Box, Text } from '@chakra-ui/react';
|
import { Box, Text } from '@chakra-ui/react';
|
||||||
import { UnlockIcon } from '@chakra-ui/icons';
|
import { UnlockIcon } from '@chakra-ui/icons';
|
||||||
|
|
||||||
import { useAppDispatch } from './hooks';
|
import { useAppDispatch } from '~/hooks';
|
||||||
import { addNewFile, processFile } from './features/file-listing/fileListingSlice';
|
import { addNewFile, processFile } from '~/features/file-listing/fileListingSlice';
|
||||||
import { nanoid } from 'nanoid';
|
import { nanoid } from 'nanoid';
|
||||||
|
|
||||||
export function SelectFile() {
|
export function SelectFile() {
|
@ -1,7 +1,7 @@
|
|||||||
import { VStack } from '@chakra-ui/react';
|
import { VStack } from '@chakra-ui/react';
|
||||||
|
|
||||||
import { selectFiles } from './fileListingSlice';
|
import { selectFiles } from './fileListingSlice';
|
||||||
import { useAppSelector } from '../../hooks';
|
import { useAppSelector } from '~/hooks';
|
||||||
import { FileRow } from './FileRow';
|
import { FileRow } from './FileRow';
|
||||||
|
|
||||||
export function FileListing() {
|
export function FileListing() {
|
||||||
|
13
src/main.tsx
13
src/main.tsx
@ -1,9 +1,10 @@
|
|||||||
|
import React from 'react';
|
||||||
import ReactDOM from 'react-dom/client';
|
import ReactDOM from 'react-dom/client';
|
||||||
|
|
||||||
import { setupStore } from './store';
|
import { AppRoot } from './components/AppRoot';
|
||||||
import { Loader } from './Loader';
|
|
||||||
|
|
||||||
// Private to this file only.
|
ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
|
||||||
const store = setupStore();
|
<React.StrictMode>
|
||||||
|
<AppRoot />
|
||||||
ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(<Loader store={store} />);
|
</React.StrictMode>
|
||||||
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user