The sources of the project follows this structure:
/src
/app
/{domain}
/actions.ts
/actions.spec.ts
| // Basic Types | |
| let id: number = 5 | |
| let company: string = 'Traversy Media' | |
| let isPublished: boolean = true | |
| let x: any = 'Hello' | |
| let ids: number[] = [1, 2, 3, 4, 5] | |
| let arr: any[] = [1, true, 'Hello'] | |
| // Tuple |
| import React from 'react' | |
| import { BrowserRouter as Router, Switch } from 'react-router-dom' | |
| import routes from './routes' | |
| import FancyRoute from './components/tools/FancyRoute' | |
| const App = props => | |
| <Router> | |
| <Switch> | |
| {routes.map((route, i) => | |
| <FancyRoute key={i} {...route} /> |
| import { FieldProps } from 'formik' | |
| import React from 'react' | |
| import Select, { Option, ReactSelectProps } from 'react-select' | |
| export const SelectField: React.SFC<ReactSelectProps & FieldProps> = ({ | |
| options, | |
| field, | |
| form, | |
| }) => ( | |
| <Select |
| "use strict"; | |
| // Load plugins | |
| const autoprefixer = require("autoprefixer"); | |
| const browsersync = require("browser-sync").create(); | |
| const cp = require("child_process"); | |
| const cssnano = require("cssnano"); | |
| const del = require("del"); | |
| const eslint = require("gulp-eslint"); | |
| const gulp = require("gulp"); |
Picking the right architecture = Picking the right battles + Managing trade-offs
While this gist has been shared and followed for years, I regret not giving more background. It was originally a gist for the engineering org I was in, not a "general suggestion" for any React app.
Typically I avoid folders altogether. Heck, I even avoid new files. If I can build an app with one 2000 line file I will. New files and folders are a pain.
| function humanize(num){ | |
| var ones = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', | |
| 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', | |
| 'seventeen', 'eighteen', 'nineteen']; | |
| var tens = ['', '', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', | |
| 'ninety']; | |
| var numString = num.toString(); | |
| if (num < 0) throw new Error('Negative numbers are not supported.'); |
| // String utils | |
| // | |
| // resources: | |
| // -- mout, https://github.com/mout/mout/tree/master/src/string | |
| /** | |
| * "Safer" String.toLowerCase() | |
| */ | |
| function lowerCase(str) { | |
| return str.toLowerCase(); |