6 |
7 | Inspired by:
8 |
9 | - [Material-UI](https://github.com/mui-org/material-ui)
10 | - [react-redux-typescript-boilerplate](https://github.com/rokoroku/react-redux-typescript-boilerplate)
11 |
12 | ## Contains
13 |
14 | - [x] [Material-UI](https://github.com/mui-org/material-ui)
15 | - [x] [Typescript](https://www.typescriptlang.org/)
16 | - [x] [React](https://facebook.github.io/react/)
17 | - [x] [Redux](https://github.com/reactjs/redux)
18 | - [x] [Redux-Thunk](https://github.com/gaearon/redux-thunk)
19 | - [x] [Redux-Persist](https://github.com/rt2zz/redux-persist)
20 | - [x] [React Router](https://github.com/ReactTraining/react-router)
21 | - [x] [Redux DevTools Extension](https://github.com/zalmoxisus/redux-devtools-extension)
22 | - [x] [TodoMVC example](http://todomvc.com)
23 |
24 | Optional:
25 |
26 | - [ ] Cypress-Tests-Environment
27 | - [ ] Firebase-Integration
28 | - [ ] Github Actions (cypress-test, build-and-deploy to firebase)
29 | - [ ] Snackbars
30 | - [ ] Subfolder Library
31 | - [ ] Service Worker
32 | - [ ] PolyFills (IE11)
33 |
34 |
35 | ## How to use
36 |
37 | We made a CLI Tool [react-factory](https://github.com/innFactory/react-factory) to include more options.
38 |
39 |
40 |
41 | First install [Yeoman](http://yeoman.io) and the CLI Tool:
42 | ```bash
43 | npm install -g yo
44 | npm install -g generator-react-factory
45 | ```
46 |
47 | Then generate your new project:
48 |
49 | ```bash
50 | yo react-factory
51 | ```
52 |
53 |
54 |
55 | ## Enable Prettier [OPTIONAL]
56 |
57 | 1. Step: Install the Prettier plugin (e.g. the one of Esben Petersen)
58 | 2. Add the following snippet to your settings in VSCode:
59 |
60 | ```json
61 | "editor.formatOnSave": true,
62 | "editor.codeActionsOnSave": {
63 | "source.organizeImports": true // optional
64 | },
65 | ```
66 |
67 | ## Enable project snippets [OPTIONAL]
68 |
69 | Just install following extension:
70 |
71 |
72 |
73 | After that you can start to type `fcomp` (_for function component_) and you get a template for a new component.
74 |
75 |
76 |
77 |
78 | ## The idea behind the example
79 |
80 | This example demonstrate how you can use [Create React App](https://github.com/facebookincubator/create-react-app) with [TypeScript](https://github.com/Microsoft/TypeScript).
81 |
82 | ## Contributors
83 |
84 | - [Anton Spöck](https://github.com/spoeck)
85 |
86 | Powered by [innFactory](https://innfactory.de/)
87 |
--------------------------------------------------------------------------------
/src/App.tsx:
--------------------------------------------------------------------------------
1 | // prettier-ignore
2 | import { AppBar, IconButton, Toolbar, Typography, useMediaQuery } from "@material-ui/core";
3 | import { Theme } from "@material-ui/core/styles";
4 | import MenuIcon from "@material-ui/icons/Menu";
5 | import { makeStyles } from "@material-ui/styles";
6 | import * as React from "react";
7 | import { Router } from "react-router-dom";
8 | import { RouterSwitch } from 'react-typesafe-routes';
9 | import { Drawer } from "./components/Drawer";
10 | import { history } from "./configureStore";
11 | import { withRoot } from "./withRoot";
12 | import { useSelector } from 'react-redux';
13 | import { useActions } from './actions';
14 | import * as ConfigActions from './actions/config';
15 | import { RootState } from "./reducers";
16 | import { router } from "./Router";
17 |
18 | import { Snackbar } from './components/Snackbar';
19 |
20 | function App() {
21 | const classes = useStyles();
22 | const drawerOpen: boolean = useSelector((state: RootState) => state.drawerOpen);
23 | const configActions: typeof ConfigActions = useActions(ConfigActions);
24 | const isMobile = useMediaQuery((theme: Theme) =>
25 | theme.breakpoints.down("sm")
26 | );
27 |
28 | const handleDrawerToggle = () => {
29 | configActions.setDrawerOpen(!drawerOpen);
30 | };
31 |
32 |
33 | return (
34 |