Skip to content

Commit 3e11202

Browse files
committed
update docs
1 parent 6f8fdd7 commit 3e11202

16 files changed

+168
-118
lines changed

README.md

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Bulletproof React 🛡️ ⚛️
22

3-
[![MIT License](https://img.shields.io/apm/l/atomic-design-ui.svg?)](https://github.com/tterb/atomic-design-ui/blob/master/LICENSEs)
3+
[![MIT License](https://img.shields.io/apm/l/atomic-design-ui.svg?)](https://github.com/tterb/atomic-design-ui/blob/master/LICENSEs)
44
[![CI](https://github.com/alan2207/bulletproof-react/actions/workflows/ci.yml/badge.svg)](https://github.com/alan2207/bulletproof-react/actions/workflows/ci.yml)
55

66
A simple, scalable, and powerful architecture for building production ready React applications.
@@ -10,30 +10,31 @@ A simple, scalable, and powerful architecture for building production ready Reac
1010
React is a great tool for building frontend applications. It has a very diverse ecosystem with hundreds of great libraries for literally anything you might need. However, it can be overwhelming to be forced to make so many choices.
1111
It is also very flexible, you can write React applications in any way you like but that flexibility comes with a cost. Since there is no pre-defined architecture developers can follow, it often leads to messy, inconsistent, or over-complicated codebases.
1212

13-
This is an attempt to present the way of creating React applications using the best tools in the ecosystem with a good project structure that scales very well. It is based on the experience of working with many different codebases, and this architecture turns out to be the most effective one.
13+
This is an attempt to present a way of creating React applications using the best tools in the ecosystem with a good project structure that scales very well. It is based on the experience of working with many different codebases, and this architecture turns out to be the most effective one.
1414

15-
The goal of this repo is to serve as a collection of good practices when developing React applications. It is supposed to showcase solving most of the real-world problems of an application in a practical way and help developers writing better applications.
15+
The goal of this repo is to serve as a collection of resources and good practices when developing React applications. It is supposed to showcase solving most of the real-world problems of an application in a practical way and help developers writing better applications.
1616

1717
Feel free to explore the codebase to get the most value out of the repo.
1818

1919
#### Disclaimer:
2020

21-
This is not supposed to be a template, boilerplate or a framework. It is an opinionated guide that shows how to do some things in a certain way. You are not forced to do everything exactly as it is shown here, decide what works best for you and your team and be consistent with your style.
21+
This is not supposed to be a template, boilerplate or a framework. It is an opinionated guide that shows how to do some things in a certain way. You are not forced to do everything exactly as it is shown here, decide what works best for you and your team and stay consistent with your style.
2222

2323
## Table Of Contents:
2424

25-
- [The Application Overview](docs/application-overview.md)
26-
- [Project Configuration](docs/project-configuration.md)
27-
- [Project Structure](docs/project-structure.md)
28-
- [Components And Styling](docs/components-and-styling.md)
29-
- [Forms](docs/forms.md)
30-
- [API Layer](docs/api-layer.md)
31-
- [State Management](docs/state-management.md)
32-
- [Auth](docs/auth.md)
33-
- [API Mock Server](docs/api-mock-server.md)
34-
- [Testing](docs/testing.md)
35-
- [Error Handling](docs/error-handling.md)
36-
- [Performance](docs/performance.md)
25+
- [💻 Application Overview](docs/application-overview.md)
26+
- [⚙️ Project Configuration](docs/project-configuration.md)
27+
- [👁️ Style Guide](docs/style-guide.md)
28+
- [🗄️ Project Structure](docs/project-structure.md)
29+
- [🧱 Components And Styling](docs/components-and-styling.md)
30+
- [📡 API Layer](docs/api-layer.md)
31+
- [🗃️ State Management](docs/state-management.md)
32+
- [🧪 Testing](docs/testing.md)
33+
- [⚠️ Error Handling](docs/error-handling.md)
34+
- [🔐 Security](docs/security.md)
35+
- [🚄 Performance](docs/performance.md)
36+
- [🌐 Deployment](docs/deployment.md)
37+
- [📚 Additional Resources](docs/additional-resources.md)
3738

3839
## Contributing
3940

docs/additional-resources.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# 📚 Additional Resources
2+
3+
## React
4+
5+
[Official Documentation](https://pt-br.reactjs.org/docs/getting-started.html)
6+
[React Bits](https://github.com/vasanthk/react-bits)
7+
[React Patterns](https://reactpatterns.com/)
8+
[Tao Of React](https://alexkondov.com/tao-of-react/)
9+
10+
## JavaScript
11+
12+
[You Dont Know JS](https://github.com/getify/You-Dont-Know-JS)
13+
[JavaScript Info](https://javascript.info/)
14+
[33 Concepts Every JavaScript Developer Should Know](https://github.com/leonardomso/33-js-concepts#8-iife-modules-and-namespaces)
15+
[JavaScript to Know for React](https://kentcdodds.com/blog/javascript-to-know-for-react)

docs/api-layer.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# API Layer
1+
# 📡 API Layer
22

33
### Use a single instance of the API client
44

docs/api-mock-server.md

Lines changed: 0 additions & 11 deletions
This file was deleted.

docs/application-overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# The Application Overview
1+
# 💻 Application Overview
22

33
The application is pretty simple. Users can create teams where other users can join, and they start discussions on different topics between each other.
44

docs/components-and-styling.md

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
# Components And Styling
1+
# 🧱 Components And Styling
22

33
## Components Best Practices
44

5-
#### Collocate things as close as possible to where it's being used
5+
#### Colocate things as close as possible to where it's being used
66

7-
Keep components, functions, styles, state, etc. as close as possible to the component where it's being used.
7+
Keep components, functions, styles, state, etc. as close as possible to the component where it's being used. This will not only make your codebase more readable and easier to understand but it will also improve your application performance since it will reduce redundant re-renders on state updates.
88

9-
#### Avoid nested rendering functions
9+
#### Avoid large components with nested rendering functions
10+
11+
Do not add multiple rendering functions inside your application, this gets out of control pretty quickly. What you should do instead is if there is a piece of UI that can be considered as a unit, is to extract it in a separate component.
1012

1113
```javascript
1214
// this is very difficult to maintain as soon as the component starts growing
@@ -18,7 +20,9 @@ function Component() {
1820
}
1921

2022
// extract it in a separate component
21-
import { Items } from 'components/Items';
23+
function Items() {
24+
return <ul>...</ul>;
25+
}
2226

2327
function Component() {
2428
return (
@@ -31,11 +35,11 @@ function Component() {
3135

3236
#### Stay consistent
3337

34-
Keep your code style consistent. e.g If you name your components by using pascal case, do it everywhere. If you create components as arrow functions, do it everywhere.
38+
Keep your code style consistent. e.g If you name your components by using pascal case, do it everywhere. More on this can be found [here](./style-guide.md)
3539

3640
#### Limit the number of props a component is accepting as input
3741

38-
If your component accepts a lot of props you might consider splitting it into multiple components or use composition via children or slots.
42+
If your component is accepting too many props you might consider splitting it into multiple components or use the composition technique via children or slots.
3943

4044
[Composition Example Code](../src/components/Elements/ConfirmationDialog/ConfirmationDialog.tsx)
4145

@@ -55,22 +59,24 @@ Every project requires some UI components such as modals, tabs, sidebars, menus,
5559

5660
#### Fully featured component libraries:
5761

58-
- [Chakra UI](https://chakra-ui.com/) - great library with probably the best developer experience, allows very fast prototyping with decent design defaults. Plenty of components that are very flexible with accessibility already configured out of the box.
62+
These component libraries come with their components fully styled.
63+
64+
- [Chakra UI](https://chakra-ui.com/) - great library with probably the best developer experience, allows very fast prototyping with decent design defaults. Plenty of components that are very customizable and flexible with accessibility already configured out of the box.
5965

6066
- [AntD](https://ant.design/) - another great component library that has a lot of different components. Best suitable for creating admin dashboards. However, it might be a bit difficult to change the styles in order to adapt it to a custom design.
6167

6268
- [Material UI](https://material-ui.com/) - the most popular component library for React. Has a lot of different components. It might be more suitable for building admin dashboards as it would not be easy to change the components to look like something else than Material Design.
6369

6470
#### Headless component libraries:
6571

66-
If you have a specific design system from your designer, it might be easier and better solution to go with headless components that come unstyled than to adapt a fully featured library components such as Material UI to your needs. Some good options are:
72+
These component libraries come with their components unstyled. If you have a specific design system to implement, it might be easier and better solution to go with headless components that come unstyled than to adapt a styled components library such as Material UI to your needs. Some good options are:
6773

6874
- [Reakit](https://reakit.io/)
6975
- [Headless UI](https://headlessui.dev/)
7076
- [Radix UI](https://www.radix-ui.com/)
7177
- [react-aria](https://react-spectrum.adobe.com/react-aria/)
7278

73-
## Styling libraries
79+
## Styling Solutions
7480

7581
There are multiple ways to style a react application. Some good options are:
7682

@@ -84,12 +90,14 @@ There are multiple ways to style a react application. Some good options are:
8490

8591
## Good combinations
8692

93+
Some good combinations of component library + styling
94+
8795
- [Chakra UI](https://chakra-ui.com/) + [emotion](https://emotion.sh/docs/introduction) - The best choice for most applications
8896
- [Headless UI](https://headlessui.dev/) + [tailwind](https://tailwindcss.com/)
8997
- [Radix UI](https://www.radix-ui.com/) + [stitches](https://stitches.dev/)
9098

9199
## Storybook
92100

93-
[Storybook](https://storybook.js.org/) is a great tool for developing and testing components in isolation. Think of it as a catalogue of all the components your application is using. Very useful especially for larger projects because it helps exploring components.
101+
[Storybook](https://storybook.js.org/) is a great tool for developing and testing components in isolation. Think of it as a catalogue of all the components your application is using. Very useful for developing and discoverability of components.
94102

95103
[Storybook Story Example Code](../src/components/Elements/Button/Button.stories.tsx)

docs/deployment.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# 🌐 Deployment
2+
3+
Deploy and serve your applications and assets over a CDN for best delivery and performance. Good options for that are:
4+
5+
- [Vercel](https://vercel.com/)
6+
- [Netlify](https://www.netlify.com/)
7+
- [AWS](https://aws.amazon.com/cloudfront/)
8+
- [CloudFlare](https://www.cloudflare.com/en-gb/cdn/)

docs/error-handling.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# Error Handling
1+
# ⚠️ Error Handling
22

33
### API Errors
44

5-
Set up an interceptor for handling errors. You might want to fire a notification toast to notify users that something went wrong.
5+
Set up an interceptor for handling errors. You can use it to fire a notification toast to notify users that something went wrong, log out unauthorized users, or send new requests for refreshing tokens.
66

77
[API Errors Notification Example Code](../src/lib/axios.ts)
88

docs/forms.md

Lines changed: 0 additions & 26 deletions
This file was deleted.

docs/performance.md

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
# Performance
1+
# 🚄 Performance
22

33
### Code Splitting
44

5-
Code splitting is a technique of splitting production js into smaller pieces, thus allowing the application to be only partially downloaded. Any unused code will not be downloaded until it is required by the application.
5+
Code splitting is a technique of splitting production JavaScript into smaller files, thus allowing the application to be only partially downloaded. Any unused code will not be downloaded until it is required by the application.
66

7-
Most of the time code splitting should be done on the routes level.
7+
Most of the time code splitting should be done on the routes level, but can also be used for other lazy loaded parts of application.
88

99
Do not code split everything as it might even worsen your application's performance.
1010

1111
[Code Splitting Example Code](../src/routes/index.tsx)
1212

1313
### Component and state optimizations
1414

15-
- Do not put everything in a single context. That might trigger unnecessary re-renders. Instead split the global state into multiple contexts.
15+
- Do not put everything in a single state. That might trigger unnecessary re-renders. Instead split the global state into multiple stores according to where it is being used.
1616

1717
- Keep the state as close as possible to where it is being used. This will prevent re-rendering components that do not depend on the updated state.
1818

@@ -36,15 +36,8 @@ Consider lazy loading images that are not in the viewport.
3636

3737
Use modern image formats such as WEBP for faster image loading.
3838

39+
Use `srcset` to load the most optimal image for the clients screen size.
40+
3941
### Web vitals
4042

4143
Since Google started taking web vitals in account when indexing websites, you should keep an eye on web vitals scores from [Lighthouse](https://web.dev/measure/) and [Pagespeed Insights](https://developers.google.com/speed/pagespeed/insights/).
42-
43-
### Deployment
44-
45-
Deploy and serve your application and assets over a CDN. Good options for that are:
46-
47-
- [Vercel](https://vercel.com/)
48-
- [Netlify](https://www.netlify.com/)
49-
- [AWS](https://aws.amazon.com/cloudfront/)
50-
- [CloudFlare](https://www.cloudflare.com/en-gb/cdn/)

0 commit comments

Comments
 (0)