Giter VIP home page Giter VIP logo

rbiedrawa / react-redux-rtk-saga-mui-typescript-starter Goto Github PK

View Code? Open in Web Editor NEW
29.0 1.0 17.0 4.07 MB

A boilerplate Create React App with Typescript, Redux Toolkit, Redux Saga, React Hook Form, Cypress, Storybook, React-i18next and Material UI๐Ÿ‘จโ€๐Ÿ’ป

License: MIT License

HTML 1.31% TypeScript 74.16% Shell 0.43% JavaScript 24.11%
reactjs react typescript material-ui redux redux-saga redux-toolkit react-router react-hook-form yup

react-redux-rtk-saga-mui-typescript-starter's Introduction

react-redux-rtk-saga-mui-typescript-starter

ts react redux redux-saga mui storybook jest cypress license


Table of Content

About

about.gif

Features

  1. React.js CRUD example with Redux Saga.
  2. Typescript for type safety
  3. Core libraries
  4. Test libraries
  5. Other tools/libraries
  6. Opinionated folder structure
  7. Internationalization for react app using React-i18next
  8. Material UI Dark Mode support

Project Structure

./src
โ”œโ”€โ”€ App.tsx # Application entrypoint
โ”œโ”€โ”€ assets # assets folder contains all the static files (images, fonts, etc).
โ”œโ”€โ”€ components # shared components
โ”œโ”€โ”€ config # global configuration, env variables etc.
โ”‚ย ย  โ”œโ”€โ”€ Env.ts
โ”‚ย ย  โ””โ”€โ”€ i18n
โ”œโ”€โ”€ features
โ”‚ย ย  โ”œโ”€โ”€ feature # 'feature'
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ api # API folder contains http service calls
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ assets # 'feature' assets folder
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ components # 'feature' components
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ hooks # 'feature' hooks
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ index.ts # entry point for 'feature' public API
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ store # 'feature' state stores contains slices, sagas, etc.
โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ types # 'feature' typescript types
โ”‚ย ย  โ””โ”€โ”€ another_feature # 'another_feature'
โ”œโ”€โ”€ hooks # shared hooks
โ”œโ”€โ”€ libs # libraries imported or exported that can be used in different projects
โ”‚ย ย  โ”œโ”€โ”€ core
โ”‚ย ย  โ””โ”€โ”€ ui
โ”œโ”€โ”€ pages  # contains all application pages
โ”œโ”€โ”€ routes # routes configuration
โ”œโ”€โ”€  store # root store and store settings
โ””โ”€โ”€ test/ # contains test utilities and Mock Service Worker setup
    โ””โ”€โ”€ msw

๐Ÿ‘จโ€๐Ÿ’ป Getting Started

Prerequisites

nvm
brew install nvm
Node.js v17
nvm install v17.4.0
Yarn
npm install --global yarn

Installation

Install NPM packages:

yarn install

Development

To start the application in the development mode run:

yarn start

๐Ÿ“ Note: Application starts in sandbox-mode, with all backend calls mocked by MSW library. To disable it change REACT_APP_MSW_ENABLED variable to false.

๐Ÿ’ก Tip: Open http://localhost:3000 to view application in the browser.

Build

To build the application for production, run:

yarn build

Testing

Unit / Integration tests

Launch the test runner in the interactive watch mode:

yarn test

See the section about running tests for more information.

Run yarn coverage to generate code coverage.

E2E tests

posts.spec.ts

To run e2e use below command:

yarn build && yarn test:e2e

๐Ÿ“ Note: This script will start the server, wait until application is running, execute e2e tests and after that it will shut down the server.

๐Ÿ’ก Tip: To run Cypress in interactive mode, start the application and run yarn cy:open

Storybook

Start Storybook in development mode:

yarn storybook

To build Storybook as static web application, run the following command inside project's root directory:

yarn build-storybook

๐Ÿ’ก Tip: run npx http-server ./storybook-static to preview static web application locally.

๐Ÿ‘ฎ Code Quality

Overview

Running the script yarn format will format the code style of all TypeScript files.

The script yarn lint will run linter in the project. If any code standards or styles are not met in code, it will display the errors or warnings.

Run yarn lint:fix command to format code and fix automatically any error found - if the linter knows how to fix it๐Ÿ˜‰.

๐Ÿ’ก Tip: To enforce code conventions and prevent bad commits this project is setup to use Husky. Husky is used to run validation and format code before every commit. Additionally, it will check if git message is following conventional commits format.

Absolute imports

Absolute imports should always be configured and used because it makes it easier to move files around and avoid messy import paths such as ../../../Component. Wherever you move the file, all the imports will remain intact.

To enable Absoulte imports in Intelij ide go to Settings -> Editor -> Code Style -> TypeScript -> Imports and enable Use paths relative to tsconfig.json.

๐Ÿ˜ˆ Release

Create release version and generate a changelog file:

GITHUB_TOKEN=YOUR-TOKEN yarn release

๐Ÿ’ก Tip: --no-ci - allows you to trigger release from no ci environment e.g. local

๐Ÿ’ก Tip: yarn release:dry-run - allows you to see what commands would be run, without committing to git or updating files.

๐Ÿ›  Useful dev tools

๐ŸŽ“ References

๐Ÿ‘จโ€๐ŸŽ“ Additional Links

License

Distributed under the MIT License. See LICENSE for more information.

react-redux-rtk-saga-mui-typescript-starter's People

Contributors

rbiedrawa avatar semantic-release-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

react-redux-rtk-saga-mui-typescript-starter's Issues

"No files matching the pattern" error on initial windows checkin

If you create a repo from this code on the initial checkin under windows you get an error about this line:

"lint:css": "stylelint './src/**/*.{jsx,js,tsx,ts}'",

If you get it to eventually do the initial check in, you can undo whatever hacks you had to do to get it to checkin and future checkins seem OK... googling seems to indicate this is a windows only issue related to the single quotes. Removing them gets rid of the error. Updating the packages may help too seems like there were some bugfixes related to this.

Error after clone & start

Hi,
Here what i did:

git clone ...,
npm i,
npm run start

Result:

Failed to compile.

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './runtime.js' is not defined by "exports" in /home/user/Documents/progs/react_boiler/react-redux-rtk-saga-mui-typescript-starter/node_modules/react-refresh/package.json
asset static/js/bundle.js 313 KiB [emitted] (name: main) 1 related asset
asset index.html 658 bytes [emitted]
asset asset-manifest.json 190 bytes [emitted]
runtime modules 28.2 KiB 13 modules
modules by path ./node_modules/core-js-pure/ 24.8 KiB 53 modules
modules by path ./node_modules/webpack-dev-server/client/ 62.1 KiB 12 modules
modules by path ./node_modules/webpack/hot/*.js 4.4 KiB
./node_modules/webpack/hot/dev-server.js 1.63 KiB [built] [code generated]
./node_modules/webpack/hot/log.js 1.37 KiB [built] [code generated]

  • 2 modules
    modules by path ./node_modules/html-entities/lib/*.js 115 KiB
    ./node_modules/html-entities/lib/index.js 6.83 KiB [built] [code generated]
    ./node_modules/html-entities/lib/named-references.js 107 KiB [built] [code generated]
  • 2 modules
    ./node_modules/@pmmmwh/react-refresh-webpack-plugin/client/ReactRefreshEntry.js 849 bytes [built] [code generated]
    ./src/index.tsx 39 bytes [not cacheable] [built] [code generated] [1 error]
    ./node_modules/ansi-html-community/index.js 4.26 KiB [built] [code generated]
    ./node_modules/events/events.js 14 KiB [built] [code generated]

ERROR in ./src/index.tsx
Module build failed (from ./node_modules/@pmmmwh/react-refresh-webpack-plugin/loader/index.js):
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './runtime.js' is not defined by "exports" in /home/user/Documents/progs/react_boiler/react-redux-rtk-saga-mui-typescript-starter/node_modules/react-refresh/package.json
at new NodeError (node:internal/errors:371:5)
at throwExportsNotFound (node:internal/modules/esm/resolve:440:9)
at packageExportsResolve (node:internal/modules/esm/resolve:692:3)
at resolveExports (node:internal/modules/cjs/loader:482:36)
at Function.Module._findPath (node:internal/modules/cjs/loader:522:31)
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27)
at Function.resolve (node:internal/modules/cjs/helpers:108:19)
at Object. (/home/user/Documents/progs/react_boiler/react-redux-rtk-saga-mui-typescript-starter/node_modules/@pmmmwh/react-refresh-webpack-plugin/loader/index.js:20:4)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)

ERROR in ./node_modules/@pmmmwh/react-refresh-webpack-plugin/client/ReactRefreshEntry.js 4:23-58
Module not found: Error: Package path ./runtime.js is not exported from package /home/user/Documents/progs/react_boiler/react-redux-rtk-saga-mui-typescript-starter/node_modules/react-refresh (see exports field in /home/user/Documents/progs/react_boiler/react-redux-rtk-saga-mui-typescript-starter/node_modules/react-refresh/package.json)

webpack 5.70.0 compiled with 2 errors in 11334 ms

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.