Ensure: that your versions of node and npm are up to date by running:
$ node -v; npm -v;
v10.4.0
6.1.0Clone this repository on your local machine
$ git clone https://github.com/bitadj/starter-react.git
$ npm i
$ npm startThe app will automatically open your browser to http://localhost:8484/
We recommend that you download a linter for your code editor for use with eslint
Starter React utilizes the following tools/libraries (As of September 21, 2018):
- React 16
- Redux
- Axios
- Babel 7
- Webpack 4
- Hot Module Replacement
- Eslint
- Sass
- Jest
- Lodash (as lodash-es)
-
Each feature is located within its own folder (named using
PascalCase) under thesrc/directory and contains anindex.jsxat the top level -
A feature may be comprised of multiple components, in which case there will be a
componentsfolder within the feature directory with ajsxfile for each component and may have anindex.jsfile for named exports -
If a feature utilizes redux, there are folders for
actionsandreducers -
Test files have the same filename (using
PascalCase) as the components/util being tested with the.test.jsextension (i.e.MyComponent.test.js) and are located in the same directory as the component/util -
Utility and helper functions are located in a
utilsfolder with anindex.jsfor exports
-
Within ghe
src/directory there is also astylesheetsdirectory. -
The stylesheets for each component are located within their own directory under the
stylesheets/modulesdirectory. -
Each stylesheet has the same filename (using
snake-case) as the associated component and is prefixed with an underscore (i.e._my-component.scss) -
Each new module is imported in
main.scss(i.e.@import "modules/Cases/cases.scss";)
.
src/
Cases/
actions/
fetchCases.js
fetchCases.test.js
components/
CasesItem.jsx
CasesItem.test.js
reducers/
casesReducer.js
casesReducer.test.js
utils/
formatCaseData.js
formatCaseData.test.js
selectCase.test.js
selectCase.js
index.js
index.jsx
index.test.js
AnotherComponent/
stylesheets/
modules/
App/
Cases/
_cases.scss
AnotherComponent/
_another-component.scss
_variables.scss
main.scss
Starter React takes advantage of @babel/plugin-module-resolver for absolute import statements.
The testing environment is written in Jest and Enzyme. Please ensure your components and utilities are thoroughly tested by running a test coverage report. Test files have the same name as the components/util being tested with the .test.js extension and are located in the same directory as the component/util.
There are a number of options for running tests:
| Script | Result |
|---|---|
npm run test |
run all tests once |
npm run test:watch |
run tests in watch mode |
npm run test:coverage |
creates a coverage report in ./coverage directory opens coverage report in browser |
To see a treemap of the production bundle, run npm run analyze