Skip to content

Commit 5a8b1e4

Browse files
committed
add react-query, update readme, add context to App
1 parent d18735c commit 5a8b1e4

4 files changed

Lines changed: 39 additions & 10 deletions

File tree

package.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,22 @@
6161
}
6262
},
6363
"lint-staged": {
64-
"*.+(js|jsx)": ["eslint --fix", "git add"],
65-
"*.+(json|css|md)": ["prettier --write", "git add"]
64+
"*.+(js|jsx)": [
65+
"eslint --fix",
66+
"git add"
67+
],
68+
"*.+(json|css|md)": [
69+
"prettier --write",
70+
"git add"
71+
]
6672
},
6773
"dependencies": {
6874
"compare-versions": "^3.6.0",
6975
"dotenv": "^8.2.0",
7076
"prop-types": "^15.7.2",
7177
"react": "^17.0.1",
7278
"react-dom": "^17.0.1",
79+
"react-query": "^3.6.0",
7380
"shelljs": "^0.8.4"
7481
}
7582
}

readme.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,29 @@ React v17<br>
66
Webpack 5<br>
77
SCSS<br>
88
Jest/React Testing Library<br>
9-
Env Files<br>
109
PropTypes<br>
10+
ESLint & Prettier<br>
11+
Env Files<br>
1112

1213
## Setup
1314

14-
Run `git clone https://github.com/ilyasudakov/basic-react-boilerplate.git` to clone repository<br>
15-
Run `npm run setup` to initiate setup process, where you can create new repo if you want to<br>
16-
Then you can `npm run start` to view template app
15+
1. Run `git clone https://github.com/ilyasudakov/basic-react-boilerplate.git <YOUR_PROJECT_NAME>` to clone repository<br>
16+
17+
2. Change working directory to your project directory `cd <YOUR_PROJECT_NAME>`<br>
18+
19+
3. Run `npm run setup` to initiate setup process, where you can create new repo if you want to<br>
20+
21+
4. Then you can `npm run start` to view template app
1722

1823
## Commands
1924

2025
Run `npm i` to install all dependencies<br>
2126
Run `npm run dev` to run app in development mode<br>
2227
Run `npm run start` to serve files to `/public` folder<br>
2328
Run `npm run test` to run tests<br>
29+
30+
## Questions
31+
32+
- Q: Why no Redux?
33+
34+
A: Too much boilercode, hard to maintain and slow to code. Rather use React-Query, which fetches, parses, caches data for you. Or in case if need global storage for your app, React Context will probably do fine , but in huge apps where global state changes frequently - Redux is probably better option

src/components/App.jsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
11
import React from 'react';
2+
const AppContext = React.createContext();
23

3-
const App = () => {
4-
return <div>App</div>;
4+
export const App = () => {
5+
return (
6+
<AppContext.Provider
7+
value={
8+
{
9+
//your context state variables go here
10+
}
11+
}
12+
>
13+
<div>App</div>
14+
</AppContext.Provider>
15+
);
516
};
617

7-
export default App;
18+
export default AppContext;

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
22
import ReactDOM from 'react-dom';
3-
import App from './components/App.jsx';
3+
import { App } from './components/App.jsx';
44

55
ReactDOM.render(<App />, document.getElementById('root'));

0 commit comments

Comments
 (0)