Skip to content

Commit

Permalink
[ADDED] module 20-9
Browse files Browse the repository at this point in the history
  • Loading branch information
montasim committed Jul 23, 2023
1 parent 9cf8a77 commit 22e6eea
Show file tree
Hide file tree
Showing 35 changed files with 2,511 additions and 26 deletions.
1 change: 1 addition & 0 deletions .idea/Next-Level-Web-Development.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/jsLibraryMappings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 32 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<br/>

All of the codes, notes, and ideas from the Next Level Web Development courses will be added here.
All the codes, notes, and ideas from the Next Level Web Development courses will be added here.

<br/>

Expand Down Expand Up @@ -176,21 +176,27 @@ NOTE: Notes will be added by Mission name

## USED PACKAGES

- [yarn](https://yarnpkg.com/) - *Yarn is a package manager that doubles down as project manager*
- [typescript](https://www.typescriptlang.org/) - *TypeScript is JavaScript with syntax for types*
- [nodemon](https://nodemon.io/) - *Simple monitor script for use during development of a Node.js app*
- [ts-node-dev](https://www.npmjs.com/package/ts-node-dev) - *TypeScript execution environment and REPL for node.js*
- [antd](https://ant.design/docs/react/introduce) - *An enterprise-class UI design language and React UI library with a set of high-quality React components, one of best React UI library for enterprises*
- [json-server](https://www.npmjs.com/package/json-server) - *Get a full fake REST API with zero coding in less than 30 seconds (seriously)*
- [react-redux](https://redux-toolkit.js.org/tutorials/quick-start) - *The official, opinionated, batteries-included toolset for efficient Redux development*
- [mongodb](https://www.npmjs.com/package/mongodb) - *The official MongoDB driver for Node.js.*
1. [yarn](https://yarnpkg.com/) - *Yarn is a package manager that doubles down as project manager*
2. [typescript](https://www.typescriptlang.org/) - *TypeScript is JavaScript with syntax for types*
3. [nodemon](https://nodemon.io/) - *Simple monitor script for use during development of a Node.js app*
4. [ts-node-dev](https://www.npmjs.com/package/ts-node-dev) - *TypeScript execution environment and REPL for node.js*
5. [antd](https://ant.design/docs/react/introduce) - *An enterprise-class UI design language and React UI library with a set of high-quality React components, one of best React UI library for enterprises*
6. [json-server](https://www.npmjs.com/package/json-server) - *Get a full fake REST API with zero coding in less than 30 seconds (seriously)*
7. [react-redux](https://redux-toolkit.js.org/tutorials/quick-start) - *The official, opinionated, batteries-included toolset for efficient Redux development*
8. [mongodb](https://www.npmjs.com/package/mongodb) - *The official MongoDB driver for Node.js.*
9. [vite](https://vitejs.dev/guide/) - *Next Generation Frontend Tooling.*
10. [tailwindcss](https://tailwindcss.com/docs/installation) - *A utility-first CSS framework.*
11. [react-router-dom](https://reactrouter.com/en/main/start/tutorial#setup) - *React Router enables "client side routing".*
12. [@reduxjs/toolkit](https://redux-toolkit.js.org/introduction/getting-started) - *The Redux Toolkit package is intended to be the standard way to write Redux logic.*
13. [react-redux](https://react-redux.js.org/introduction/getting-started) - *React Redux is the official React UI bindings layer for Redux.*

<br/>

## TOOLS

- [typescript-mongoose-eslint-husky-staged boilerplate](https://github.com/tauhid-hasan-dev/typescript-mongo-mongoose-express-server-with-eslint-prettier-husky-lint-staged)
- [BreakTimer](https://breaktimer.app/#download)
1. [typescript-mongoose-eslint-husky-staged boilerplate](https://github.com/tauhid-hasan-dev/typescript-mongo-mongoose-express-server-with-eslint-prettier-husky-lint-staged)
2. [BreakTimer](https://breaktimer.app/#download)
3. [Redux DevTools](https://microsoftedge.microsoft.com/addons/detail/redux-devtools/nnkgneoiohoecpdiaponcejilbhhikei)

<br/>

Expand Down Expand Up @@ -263,14 +269,14 @@ If you need to change the environment variable of `Vercel` production always mak

## TUTORIALS

- [Git - How to Duplicate a Repository with History ( Full duplicate, no fork)](https://www.youtube.com/watch?v=lhlUOSfZu24)
- [How to test a local website on your phone](https://www.youtube.com/watch?v=uRYHX4EwYYA)
1. [Git - How to Duplicate a Repository with History ( Full duplicate, no fork)](https://www.youtube.com/watch?v=lhlUOSfZu24)
2. [How to test a local website on your phone](https://www.youtube.com/watch?v=uRYHX4EwYYA)

<br/>

## INSPIRATIONS

- [Wallpaper - For daily inspiration](./media/images/inspiration-wallpaper.jpeg)
1. [Wallpaper - For daily inspiration](./media/images/inspiration-wallpaper.jpeg)

<br/>

Expand All @@ -283,18 +289,18 @@ Please read the [contribution guidelines](contributing.md) first.

## SPECIAL THANKS

- [Tauhid Hasan](https://github.com/tauhid-hasan-dev) for his [typescript-mongoose-eslint-husky-staged boilerplate](https://github.com/tauhid-hasan-dev/typescript-mongo-mongoose-express-server-with-eslint-prettier-husky-lint-staged)
- [Dipto Karmaker](https://www.facebook.com/dipto.karmaker.9) for his suggestion to use [BreakTimer](https://breaktimer.app/#download)
- [Mezbaul Abedin Forhan](https://www.facebook.com/groups/196275986482127/user/100051687471216/?__cft__[0]=AZUHgThDMuNrBxWNfQMNWGsF5OF3rKdgg2DbSG3mrAe6uRnaNCNRBYD3oZ2M9U25njZjOZMMeJWUzXEMn5mWDJJIjezco9JFGBzE86Trm1__fo6EIAdKiPedc4GFe5XT0ZqJi8Mjj7PQ1jhbjFbj_ygt&__tn__=-UC%2CP-R) for [Pick Function Refactoring & Property Management](./articles/pick-function-refactoring-property-management.md)
- [Mezbaul Abedin Forhan](https://www.facebook.com/groups/196275986482127/user/100051687471216/?__cft__[0]=AZUHgThDMuNrBxWNfQMNWGsF5OF3rKdgg2DbSG3mrAe6uRnaNCNRBYD3oZ2M9U25njZjOZMMeJWUzXEMn5mWDJJIjezco9JFGBzE86Trm1__fo6EIAdKiPedc4GFe5XT0ZqJi8Mjj7PQ1jhbjFbj_ygt&__tn__=-UC%2CP-R) for [All about Express Error Handling](./articles/all-about-express-error-handling.md)
- [Mezbaul Abedin Forhan](https://www.facebook.com/groups/196275986482127/user/100051687471216/?__cft__[0]=AZUHgThDMuNrBxWNfQMNWGsF5OF3rKdgg2DbSG3mrAe6uRnaNCNRBYD3oZ2M9U25njZjOZMMeJWUzXEMn5mWDJJIjezco9JFGBzE86Trm1__fo6EIAdKiPedc4GFe5XT0ZqJi8Mjj7PQ1jhbjFbj_ygt&__tn__=-UC%2CP-R) for [MongoDB $and Operator](./articles/mongodb-and-operator.md)
- [Ehtisam Haq](https://www.facebook.com/groups/196275986482127/user/100054686322018/?__cft__[0]=AZXWZQsOJLRUlOnAZXCcdBSnHgV8L_0wHengcczizEHGUOKbtzVlWLpouOzQWUxHonIdIGpIjO8UOacomwLALreh79ZWpTrVVgYS-CcRdd8uznQtmaI7fFqpL3FAn1aOD3WWJI7xD8MEbSgo0cfw0Nco&__tn__=-UC%2CP-R) for [Exploring $exists, $type and $size operators](./articles/exploring-exists-type-and-size-operators.md)
- [Anisur Rahman](https://www.facebook.com/groups/196275986482127/user/100008280541615/?__cft__[0]=AZWt1z3R3gtFybgOz_zMiyB8XKgGZFf7GBycrIhdCV60RCskF4F_EqMwVBElP6q_RU5i0-pkfT-ZDHC6bnT2uqyQ6i1rO7F6QJuuLLhqjGp__2ENKq7qamMp0j6oSniqndu9aCVaQ7qbhzAPrFZBCgaM&__tn__=-UC%2CP-R) for [Exploring the Power of $inc, $max, $min, and $mul Operators of MongoDb](./articles/exploring-the-power-of-inc-max-min-and-mul-operators-of-mongodb.md)
- [Mehedi Anik](https://www.facebook.com/groups/196275986482127/user/100005038366015/?__cft__[0]=AZWT2tLQUda8c7i9m_lbGsy3ZAsCgKj-UOGZomNYcmWhJl0isEYWm2QkfEPGpfUUoqU1UtyRwD-zgemkiVMA5Ju6AaLu2SDX_aV2lXqwVeA_qsNqwQN-0Zr8uEtV0PN_0oorrkAeOXIW70aJhfpzMZo_&__tn__=-UC%2CP-R) for [MongoDB's Update Operators: Mastering $push, $set, and $addToSet for Efficient Data Management](./articles/mongodbs-update-operators.md)
- [Samin Israr Ravi](https://www.facebook.com/groups/196275986482127/user/100024504072245/?__cft__[0]=AZVXMf8IphXlnTvY7qwcQ0QO7uiL7oRHma-Y2f4ZYZmLuA5utedOgUforGrAAzwhRGABmlKi90kbpUgMv73adUjUM-BtRg_mDji7n4qiApFa0DLdIfx8xsNHQ-QsKBM6AgGDhkclvR7Il49uPqSpFbpW&__tn__=-UC%2CP-R) for [Unleashing the Power of Querying : Discover MongoDB's $not and $nor Operators](./articles/unleashing-the-power-of-querying.md)
- [Tanmoy Parvez](https://www.facebook.com/groups/196275986482127/user/100009656776349/?__cft__[0]=AZUTBiFBXKkM2Ou-flLonre4RhYVx3SnK18PebfVuXDUlrxpsfhojJ_LVew6cxFtkyWkZBcwnG3IZpWXN_2-NEt6wqrJhqSSQIXhgjuN5ZKkevXcd4fnDUmYmp-uC73SL7YdPz8q5V86RcSICkG3F2_e&__tn__=-UC%2CP-R) for [Boost Your MongoDB Queries: Deep Dive into $in, $nin, and $or Operators](./articles/deep-dive-into-in-nin-and-or-operators.md)
- [Simba](https://stackoverflow.com/users/5101148/simba) for [Permanently removing a file from git history](https://stackoverflow.com/questions/58161926/permanently-removing-a-file-from-git-history)
- [Jason Cheung](https://www.youtube.com/@jasoncheung94) for [Git - How to Duplicate a Repository with History ( Full duplicate, no fork)](https://www.youtube.com/watch?v=lhlUOSfZu24)
1. [Tauhid Hasan](https://github.com/tauhid-hasan-dev) for his [typescript-mongoose-eslint-husky-staged boilerplate](https://github.com/tauhid-hasan-dev/typescript-mongo-mongoose-express-server-with-eslint-prettier-husky-lint-staged)
2. [Dipto Karmaker](https://www.facebook.com/dipto.karmaker.9) for his suggestion to use [BreakTimer](https://breaktimer.app/#download)
3. [Mezbaul Abedin Forhan](https://www.facebook.com/groups/196275986482127/user/100051687471216/?__cft__[0]=AZUHgThDMuNrBxWNfQMNWGsF5OF3rKdgg2DbSG3mrAe6uRnaNCNRBYD3oZ2M9U25njZjOZMMeJWUzXEMn5mWDJJIjezco9JFGBzE86Trm1__fo6EIAdKiPedc4GFe5XT0ZqJi8Mjj7PQ1jhbjFbj_ygt&__tn__=-UC%2CP-R) for [Pick Function Refactoring & Property Management](./articles/pick-function-refactoring-property-management.md)
4. [Mezbaul Abedin Forhan](https://www.facebook.com/groups/196275986482127/user/100051687471216/?__cft__[0]=AZUHgThDMuNrBxWNfQMNWGsF5OF3rKdgg2DbSG3mrAe6uRnaNCNRBYD3oZ2M9U25njZjOZMMeJWUzXEMn5mWDJJIjezco9JFGBzE86Trm1__fo6EIAdKiPedc4GFe5XT0ZqJi8Mjj7PQ1jhbjFbj_ygt&__tn__=-UC%2CP-R) for [All about Express Error Handling](./articles/all-about-express-error-handling.md)
5. [Mezbaul Abedin Forhan](https://www.facebook.com/groups/196275986482127/user/100051687471216/?__cft__[0]=AZUHgThDMuNrBxWNfQMNWGsF5OF3rKdgg2DbSG3mrAe6uRnaNCNRBYD3oZ2M9U25njZjOZMMeJWUzXEMn5mWDJJIjezco9JFGBzE86Trm1__fo6EIAdKiPedc4GFe5XT0ZqJi8Mjj7PQ1jhbjFbj_ygt&__tn__=-UC%2CP-R) for [MongoDB $and Operator](./articles/mongodb-and-operator.md)
6. [Ehtisam Haq](https://www.facebook.com/groups/196275986482127/user/100054686322018/?__cft__[0]=AZXWZQsOJLRUlOnAZXCcdBSnHgV8L_0wHengcczizEHGUOKbtzVlWLpouOzQWUxHonIdIGpIjO8UOacomwLALreh79ZWpTrVVgYS-CcRdd8uznQtmaI7fFqpL3FAn1aOD3WWJI7xD8MEbSgo0cfw0Nco&__tn__=-UC%2CP-R) for [Exploring $exists, $type and $size operators](./articles/exploring-exists-type-and-size-operators.md)
7. [Anisur Rahman](https://www.facebook.com/groups/196275986482127/user/100008280541615/?__cft__[0]=AZWt1z3R3gtFybgOz_zMiyB8XKgGZFf7GBycrIhdCV60RCskF4F_EqMwVBElP6q_RU5i0-pkfT-ZDHC6bnT2uqyQ6i1rO7F6QJuuLLhqjGp__2ENKq7qamMp0j6oSniqndu9aCVaQ7qbhzAPrFZBCgaM&__tn__=-UC%2CP-R) for [Exploring the Power of $inc, $max, $min, and $mul Operators of MongoDb](./articles/exploring-the-power-of-inc-max-min-and-mul-operators-of-mongodb.md)
8. [Mehedi Anik](https://www.facebook.com/groups/196275986482127/user/100005038366015/?__cft__[0]=AZWT2tLQUda8c7i9m_lbGsy3ZAsCgKj-UOGZomNYcmWhJl0isEYWm2QkfEPGpfUUoqU1UtyRwD-zgemkiVMA5Ju6AaLu2SDX_aV2lXqwVeA_qsNqwQN-0Zr8uEtV0PN_0oorrkAeOXIW70aJhfpzMZo_&__tn__=-UC%2CP-R) for [MongoDB's Update Operators: Mastering $push, $set, and $addToSet for Efficient Data Management](./articles/mongodbs-update-operators.md)
9. [Samin Israr Ravi](https://www.facebook.com/groups/196275986482127/user/100024504072245/?__cft__[0]=AZVXMf8IphXlnTvY7qwcQ0QO7uiL7oRHma-Y2f4ZYZmLuA5utedOgUforGrAAzwhRGABmlKi90kbpUgMv73adUjUM-BtRg_mDji7n4qiApFa0DLdIfx8xsNHQ-QsKBM6AgGDhkclvR7Il49uPqSpFbpW&__tn__=-UC%2CP-R) for [Unleashing the Power of Querying : Discover MongoDB's $not and $nor Operators](./articles/unleashing-the-power-of-querying.md)
10. [Tanmoy Parvez](https://www.facebook.com/groups/196275986482127/user/100009656776349/?__cft__[0]=AZUTBiFBXKkM2Ou-flLonre4RhYVx3SnK18PebfVuXDUlrxpsfhojJ_LVew6cxFtkyWkZBcwnG3IZpWXN_2-NEt6wqrJhqSSQIXhgjuN5ZKkevXcd4fnDUmYmp-uC73SL7YdPz8q5V86RcSICkG3F2_e&__tn__=-UC%2CP-R) for [Boost Your MongoDB Queries: Deep Dive into $in, $nin, and $or Operators](./articles/deep-dive-into-in-nin-and-or-operators.md)
11. [Simba](https://stackoverflow.com/users/5101148/simba) for [Permanently removing a file from git history](https://stackoverflow.com/questions/58161926/permanently-removing-a-file-from-git-history)
12. [Jason Cheung](https://www.youtube.com/@jasoncheung94) for [Git - How to Duplicate a Repository with History ( Full duplicate, no fork)](https://www.youtube.com/watch?v=lhlUOSfZu24)

<br/>

Expand Down
Binary file added missions/mission-4/module-20/images/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added missions/mission-4/module-20/images/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added missions/mission-4/module-20/images/3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added missions/mission-4/module-20/images/4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
207 changes: 207 additions & 0 deletions missions/mission-4/module-20/notes.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,210 @@
<img loading="lazy" src="https://readme-typing-svg.demolab.com?font=Poppins&weight=700&size=28&duration=1&pause=1&color=EB008B&center=true&vCenter=true&repeat=false&width=680&height=40&lines=MISSION+5:+BE+A+NEXTJS+NINJA+(MODULE:+24+-+27)" alt="MISSION 5: BE A NEXTJS NINJA (MODULE: 24 - 27)" />

<img loading="lazy" src="https://readme-typing-svg.demolab.com?font=Poppins&weight=600&size=21&duration=1&pause=1&color=00B8B5&center=true&vCenter=true&repeat=false&width=590&height=21&lines=Module+20:+Get+started+with+Redux.+A+deep+dive+into+Redux's+philosophy" alt="Module 20: Get started with Redux. A deep dive into Redux's philosophy" />

<hr/>

<br/>

<details>
<summary> Text Instructions: Module 20 </summary>

```text
Module_20_Published
```
</details>

## CONTENTS:

- [20-1: Get started with Redux. A deep dive into Redux's philosophy](#20-1-get-started-with-redux-a-deep-dive-into-reduxs-philosophy)
- [20-2: Inner working of redux](#20-2-inner-working-of-redux)
- [20-3: initialize react project](#20-3-initialize-react-project)
- [20-4: File Structure and routing](#20-4-file-structure-and-routing)
- [20-5: Setup redux store.](#20-5-setup-redux-store)
- [20-6 Setup first slice](#20-6-setup-first-slice)
- [20-7: Connect component with redux store](#20-7-connect-component-with-redux-store)
- [20-8: Actions, payload and business logic](#20-8-actions-payload-and-business-logic)
- [20-9: typescript best practice and devtool](#20-9-typescript-best-practice-and-devtool)
- [20-10: Middleware and custom middleware](#20-10-middleware-and-custom-middleware)

<br/>

### 20-1: Get started with Redux. A deep dive into Redux's philosophy

1. What is Redux?

Redux is a predictable state containers for JavaScript applications.

1. Predictable

1. Single source of truth
2. Immutable behavior
3. Usage of pure function
4. Object as a function
5. Unidirectional flow

2. State Containers
1.

3. JavaScript Applications

1. Works with any JavaScript applications

2. Why use Redux?

1. Predictable state
2. Centralize state
3. Debuggable: `Redux dev tools`
4. Flexible
1. Independent UI Framework
2. Middleware support

3. Where not to use Redux?

For small project Redux is not suitable because of it's complexity.

4. Redux alternative: `MobX`

<br/>

### 20-2: Inner working of redux

1. How Redux works?

1. Action : Action taken by user. Each action has a corresponding reducer function.
2. Dispatch: Sending the action object to the store. Dispatching an action triggers the corresponding reducer to update the state.
3. Payload: Optional data that is attached to the action. It carries any additional information that needs to be sent along with the action to update the state.
4. Reducer: A reducer is a pure function that takes the current state and an actions as inputs and return a new state. It defines how the application's state changes in response to different actions.
5. Store: The store holds the state of the application. The store is responsible for dispatching actions, maintaining the state, and notifying subscribers about state changes.

<img loading="lazy" src="./images/1.png" alt="How Redux works" />
<img loading="lazy" src="./images/2.png" alt="How Redux works" />
<img loading="lazy" src="./images/3.png" alt="How Redux works" />
<img loading="lazy" src="./images/4.png" alt="How Redux works" />

<br/>

### 20-3: initialize react project

1. How to change server port for vite?

```javascript
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'

// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
server: {
port: 3000,
},
})
```

2. How to disable system auto theme for vite?

`Removes CSS` from `index.css`

<br/>

### 20-4: File Structure and routing

1. Setup react-router-dom

`/src/main.tsx`

```javascript
import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import {RouterProvider} from "react-router-dom";
import routes from "./routes";

ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<RouterProvider router={routes}/>
</React.StrictMode>,
)
```

`/src/routes/index.tsx`

```javascript
import {createBrowserRouter} from "react-router-dom";
import App from "../App";

const routes = createBrowserRouter([
{
path: "/",
element: <App/>,
},
{
path: "/home",
element: <App/>,
},
{
path: "/login",
element: <App/>,
},
]);

export default routes;
```

`/src/App.tsx`

```javascript
function App() {
return (
<>
<h1 className='bg-red-500'>Tech Net</h1>
</>
)
}

export default App;

```

<br/>

### 20-5: Setup redux store.



<br/>

### 20-6 Setup first slice



<br/>

### 20-7: Connect component with redux store



<br/>

### 20-8: Actions, payload and business logic



<br/>

### 20-9: typescript best practice and devtool



<br/>

### 20-10: Middleware and custom middleware



<br/>

## Redux

> Redux is a predictable state container for JavaScript apps.
Expand Down
18 changes: 18 additions & 0 deletions missions/mission-4/module-20/tech-net/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react-hooks/recommended',
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parser: '@typescript-eslint/parser',
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
}
24 changes: 24 additions & 0 deletions missions/mission-4/module-20/tech-net/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
Loading

0 comments on commit 22e6eea

Please sign in to comment.