A simple react boilerplate apps built with React Typescript, redux and Material Ui.
Check out the live application -> https://xenodochial-tereshkova-b7625c.netlify.app/
- axios
- react typescript
- contextApi
- redux
- redux-thunk
- i18n
- dark mode
- react error boundary
- axios interceptor
- cancel request
- authentication guards
- @casl/ability role
- role & permission based route.
- wavesurfer
- docker
- bitbucket pipeline
- Jest
- Enzyme
- E2E
- material UI
- atomic design
- eslint
- prettier
- husky
- lint-staged
- conventional commit (https://www.youtube.com/watch?v=jNxDNoYEGVU)
$ git config --global core.autocrlf false
$ git rm --cached -r .
$ git reset --hard
- eslint
- tslint
- prettier
- editorConfig for VSCode
Windows: Go to File -> Preferences -> Settings or Ctrl + ,
Adding in the settings.json file & create .vscode/settings.json in root project
{
"files.associations": {
"*.jsx": "javascriptreact"
},
"editor.insertSpaces": true,
"editor.detectIndentation": false,
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
}
}
# install husky
$ yarn run husky-install
# install node version
Please install at least v15.2.0 version node
# install npm version
Please install at least v7.0.10 version node
# install app's depndencie
$ npm install
# install typescript
$ npm install -g typescript
# dev server with PORT 3002 at http://localhost:3002/
$ npm start
# build for production with minify
$ npm run build
# run `lint` to tell you what is wrong code.
$ npm run lint
# run `format` to format all code based on your prettier and linting configuration.
$ npm run format
Component names should be like ProductCard and not like productCard, product-card, etc. This way when we see a filename in Pascal Case, it is immediately clear that the file is a react component.
This way when we search for files, we don't get a list of index.ts but will receive the actual component files.
import Product from './Product';
export default Product;
or
export { default } from './Product';
Components can be keep in components/
folder (atom, molecules...). You can refer design system of Atomic Design.
https://bradfrost.com/blog/post/atomic-web-design/
When we want to share logic between two javascript functions, we will extract it to a third function. Both components and hooks are functions, so this work for them too.
A custom Hook is a javascript function whose name starts with "use"
and that may call other hook. For example, useTranslation
below is a custom hook:
# useTranslation.tsx
import { useTranslation } from 'react-i18next';
const useTranslate = () => {
const { t: translate, i18n } = useTranslation();
return { translate, i18n };
};
export default useTranslate;
Share an function logic for our app. It name should be in lowercase. For example, sleep
below is a function.
# sleep.ts
export const sleep = time => new Promise(res => setTimeout(res, time));
├── public/ #static files
│ ├── assets/ #assets
| | |── images #images
| | |── fonts #fonts
│ └── index.html #html template
│
├── src/ #project root
| |── actions/ #actions redux
| |── apis/ #apis of feature
| |── assets/ #assets file
| |── components/ #common components reuse
│ ├── configs/ #configs project
│ ├── containers/ #containers source
| |── context/ #contextApi
| |── features/ #features of app
| |── guards/ #guard permissions
│ ├── hooks/ #hooks source
| |── layouts/ #common layouts
| |── locales/ #multi languages
│ ├── models/ #define interface
| |── reducers/ #reducers redux
| |── routes/ #common routes
| |── selectors/ #selectors redux
│ ├── services/ #services source
| |── stores/ #stores redux
| |── themes/ #themes app
│ ├── App.js
│ ├── App.test.js
│ ├── index.js
└── package.json```