# My Coding Resources

> What is this page about?
>
> I might be learning something like doing a small react or node project and so on by following some video tutorials or docs. During this, I might have learned something new from one of the videos in a large playlist or unfindable docs. It would be handy in making note of details about the features I built and where to refer to. For this reason this page is very helpful.

## HTML And CSS

| Topic                                         | Where to find                                                              | More  info                                                                                                                                                                                                              |
| --------------------------------------------- | -------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Adjust image size in img attribute            | John Smilga course - 34.                                                   |                                                                                                                                                                                                                         |
| Colors for css                                | <https://coolors.co/>                                                      | Start generator. You can click the space bar to generate new colors. If you like a single color in there and would like to find more matching colors for that one, then lock the desired color and click the space bar. |
| Images and Logo, Build header, best practices | <https://www.youtube.com/watch?v=7cwRaTqR4k0&ab_channel=LearnCode.academy> | In this video, he says how to use position relative and then use top prop to properly align the text relative to its neighbours. He says how to use background image and images in html img tag.                        |
|                                               |                                                                            |                                                                                                                                                                                                                         |

## React

| Topic                                                                                                                                                                                                                                                                                                                                                                                                                                                            | Where to find                                                                                                                                                              | More info                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <ul><li>Data fetching from different API links to different parts of the page. </li><li>During this, each API will take its own time and each part of the page will load in its own time.</li><li><strong>How to load everything at once?</strong></li></ul><p></p>                                                                                                                                                                                              | <ul><li>In Github project of John Smilga (downloaded Udemy course) you can find a lecture  on <strong>Promise.allSettled() which is Lecture Number 32.</strong> </li></ul> |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| <ul><li>Using <strong>Auth0</strong>, Authentication and Authorization </li></ul>                                                                                                                                                                                                                                                                                                                                                                                | <ul><li>Lecture 33 onwards</li></ul>                                                                                                                                       |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| <ul><li>Authentication <strong>restrict</strong> access to pages until logged in</li><li><strong>render</strong> prop in Route to dynamically show or hide the route</li><li>Use <strong>Redirect</strong> inside Route for hiding or showing route</li><li><strong>Spreading</strong> <strong>the</strong> <strong>props</strong> using rest operator </li></ul>                                                                                                | <ul><li>Lecture 36. Private Routes</li></ul>                                                                                                                               | <p>Note that we need two resources. The first one below is easily available, but second one is not easily available.</p><p></p><p><strong>For implementing Login</strong></p><p><a href="https://auth0.com/docs/quickstart/spa/react/02-calling-an-api"><https://auth0.com/docs/quickstart/spa/react/02-calling-an-api></a></p><p></p><p><strong>For implementing redirect</strong> <strong>after login (Below link is not easily available in docs)</strong></p><p><a href="https://auth0.com/docs/libraries/auth0-react"><https://auth0.com/docs/libraries/auth0-react></a></p><p></p><p><strong>Interview Q : PROBLEM FACED</strong></p><p></p><ul><li>It was not easy to implement redirect after login as this docs was not available directly on site.</li></ul> |
| <p><strong>Create-React-App + React-Router-Dom+</strong></p><p><strong>Netlify BUG</strong></p><p></p><p>There's a bug with this setup where react-router-dom gives page not found error when deployed to Netlify. The solution is shown in the video here.</p>                                                                                                                                                                                                  | Lecture Number 39. Deploy Gotchas.mp4                                                                                                                                      | <p><strong>Interview Q : PROBLEM FACED</strong></p><p></p><p><strong>Solution :</strong> Make a directory called <code>\_redirects</code> in public folder and place the below text inside</p><p></p><p> <code>/\* /index.html 200</code></p><p></p><p>Also, if there are warnings then netlify will stop the build. To avoid this, in package.json, modify the following into  below lines</p><p></p><p>"build" =  "CI = react-scripts build"</p>                                                                                                                                                                                                                                                                                                                     |
| Sidebar setup                                                                                                                                                                                                                                                                                                                                                                                                                                                    | Comfy sloth project, video 10-13                                                                                                                                           |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| Export data from a file and that data to be exported has JSX in it                                                                                                                                                                                                                                                                                                                                                                                               | Comfy sloth project, video 17- Home page - services.mp4                                                                                                                    | You can use JSX but while doing so import react from 'react' in that file and it will work                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| Dealing with numbers (like money / dollar formatting)                                                                                                                                                                                                                                                                                                                                                                                                            | Comfy sloth project, video 24. Format price.mp4                                                                                                                            | format is only to display price properly in UI. All the calculations actually we do in cents.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| react-router history (navigating to a different page)                                                                                                                                                                                                                                                                                                                                                                                                            | Comfy Sloth - 26. Single product - Loading, Error.mp4                                                                                                                      |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| Designing stars for reviews                                                                                                                                                                                                                                                                                                                                                                                                                                      | <p>Comfy Sloth - 29. Single Product Stars (manual approach).mp4 <br>and<br>30 - array approach</p>                                                                         | <p>array approach</p><p></p><p><code>{Array.from({ length: 5 }, (dontCare, index) => index + 1).map( (singleStar) => { return ( {stars >= singleStar ? ( ) : stars >= singleStar + 0.5 ? ( ) : ( )} ); } )}</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| <ul><li>Passing data <br>between contexts</li><li>Passing an imported value of something as a state value in <code>useReducer</code> is not possible. We can do it with <code>useEffect</code> </li><li>Object reference -> Products and Filtered Products both should be the same, I mean the content initially but not the pointer to it. If it's pointing to the same object then changes on one would reflect the other which is not what we need.</li></ul> | Comfy Sloth - 33. Filter Context setup.mp4                                                                                                                                 | ![](https://1944679227-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MVEiPUp08kYt33g51v7%2Fuploads%2F1H9ZO0NttG5HWDDWd69z%2Fimage.png?alt=media\&token=eb35f22e-3616-48e2-bb04-77518d1cafa1)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| Setting up sort functionality using select and option (drop-down)                                                                                                                                                                                                                                                                                                                                                                                                | Comfy Sloth - 38. Sort Component - Controlled Input.mp4                                                                                                                    |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| <ul><li>Setting up sort functionality (continued...)</li><li>How to use state value in reducer instead of passing action.payload (video time frame - 3:00)</li><li>Sort for strings - we can use localeCompare</li></ul>                                                                                                                                                                                                                                         | Comfy Sloth - 39. Sort functionality.mp4                                                                                                                                   | <p>Sort strings -> Localecompare<br><br><img src="https://1944679227-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MVEiPUp08kYt33g51v7%2Fuploads%2F3YIrumDRafWGLODq7I1Q%2Fimage.png?alt=media&#x26;token=6e0fcf17-83dd-433a-be90-4813289c714d" alt=""><br></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| Setup filters (like price range, colours, max price and so on)                                                                                                                                                                                                                                                                                                                                                                                                   | Comfy Sloth - 41. Filters - Text.mp4                                                                                                                                       | We would have so many fields on which we can filter. We can do all those by using dynamic object properties setting. Refer to the video                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| Get the value of button in react (text in button)                                                                                                                                                                                                                                                                                                                                                                                                                |                                                                                                                                                                            | e.target.textContent                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
|                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |                                                                                                                                                                            |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
|                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |                                                                                                                                                                            |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
|                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |                                                                                                                                                                            |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
|                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |                                                                                                                                                                            |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
|                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |                                                                                                                                                                            |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
|                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |                                                                                                                                                                            |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
|                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |                                                                                                                                                                            |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
|                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |                                                                                                                                                                            |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
|                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |                                                                                                                                                                            |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
|                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |                                                                                                                                                                            |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
|                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |                                                                                                                                                                            |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
|                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |                                                                                                                                                                            |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
|                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |                                                                                                                                                                            |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |

## React-Testing

| Topic                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     | Where to find                                                                                                                                                                                                                                                                                                                                         | More info                                                                                                                                                                                                           |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <ul><li>Different test methods (query methods)</li></ul>                                                                                                                                                                                                                                                                                                                                                                                                                                  | <https://www.youtube.com/watch?v=Yghw9FkNGsc&list=PL4cUxeGkcC9gm4_-5UsNmLqMosM-dzuvQ&index=5>                                                                                                                                                                                                                                                         | ![](https://1944679227-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MVEiPUp08kYt33g51v7%2Fuploads%2Fcv3CJrLG5znh12HzuQda%2Fimage.png?alt=media\&token=1b3933eb-3b49-42f7-833e-9eafb0ab6099) |
| <ul><li>Any tool to find the query methods automagically?</li></ul>                                                                                                                                                                                                                                                                                                                                                                                                                       | <ul><li>Brad Traversy channel <a href="https://www.youtube.com/watch?v=OVNjsIto9xM"><https://www.youtube.com/watch?v=OVNjsIto9xM></a></li><li>Timestamp 33:20</li></ul>                                                                                                                                                                               | Google chrome extension **Testing Playground**                                                                                                                                                                      |
| <ul><li>Integration Test</li></ul><p></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                 | <ul><li><a href="https://www.youtube.com/watch?v=6wbnwsKrnYU&#x26;list=PL4cUxeGkcC9gm4_-5UsNmLqMosM-dzuvQ&#x26;index=11&#x26;ab_channel=TheNetNinja"><https://www.youtube.com/watch?v=6wbnwsKrnYU&#x26;list=PL4cUxeGkcC9gm4_-5UsNmLqMosM-dzuvQ&#x26;index=11&#x26;ab_channel=TheNetNinja></a></li></ul>                                               |                                                                                                                                                                                                                     |
| <ul><li>Finding elements asynchronously (when page/element takes time to load) </li></ul><p></p>                                                                                                                                                                                                                                                                                                                                                                                          | <ul><li>React testing Library Playlist Tutorial 12 -  <a href="https://www.youtube.com/watch?v=V2wWLM8VX5k&#x26;list=PL4cUxeGkcC9gm4_-5UsNmLqMosM-dzuvQ&#x26;index=12&#x26;ab_channel=TheNetNinja"><https://www.youtube.com/watch?v=V2wWLM8VX5k&#x26;list=PL4cUxeGkcC9gm4_-5UsNmLqMosM-dzuvQ&#x26;index=12&#x26;ab_channel=TheNetNinja></a></li></ul> |                                                                                                                                                                                                                     |
| <ul><li>How to test when we render a list of items that are dynamic from an API</li></ul><p></p>                                                                                                                                                                                                                                                                                                                                                                                          | <ul><li>React testing Library Playlist Tutorial 12 -  <a href="https://www.youtube.com/watch?v=V2wWLM8VX5k&#x26;list=PL4cUxeGkcC9gm4_-5UsNmLqMosM-dzuvQ&#x26;index=12&#x26;ab_channel=TheNetNinja"><https://www.youtube.com/watch?v=V2wWLM8VX5k&#x26;list=PL4cUxeGkcC9gm4_-5UsNmLqMosM-dzuvQ&#x26;index=12&#x26;ab_channel=TheNetNinja></a></li></ul> |                                                                                                                                                                                                                     |
| <ul><li>How to mock data </li></ul><p></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                | <ul><li>React testing Library 13 - <a href="https://www.youtube.com/watch?v=TBZy-Rc-xX0&#x26;ab_channel=TheNetNinja"><https://www.youtube.com/watch?v=TBZy-Rc-xX0&#x26;ab_channel=TheNetNinja></a></li></ul>                                                                                                                                          |                                                                                                                                                                                                                     |
| <ul><li>Element already queried before user-event produces error. Once the DOM changes, it needs to be queried again. </li><li>Let's say we first test if element does not exist in DOM. Then, after we execute a user-event then we expect the same element to be present in DOM but that doesn't work. It doesn't work because we might be writing the expect statement based on the same query we did when element didn't exist. We need to requery again for that to pass. </li></ul> | To better understand this, watch this UDEMY Course by Laith Harb. 15. Adding the Error Handling Logic                                                                                                                                                                                                                                                 |                                                                                                                                                                                                                     |
|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |                                                                                                                                                                                                                                                                                                                                                       |                                                                                                                                                                                                                     |

## Express, Mongo and Node

| Topic                                                                                                                                                                                                                                                                                                                            | Where to find                                                                                                                                                                                                                                                                                                                  | More Info                                                                                               |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------- |
| How to limit string values in mongoose (meaning, we should be able to use only those values mentioned)                                                                                                                                                                                                                           | John Udemy node course 133. Product Model                                                                                                                                                                                                                                                                                      | You can use enum                                                                                        |
| Populate the mongo db                                                                                                                                                                                                                                                                                                            | John udemy 134. Populate DB                                                                                                                                                                                                                                                                                                    |                                                                                                         |
| User Modal mongoose                                                                                                                                                                                                                                                                                                              | John Udemy 173. User Modal                                                                                                                                                                                                                                                                                                     |                                                                                                         |
| Mongoose Schema Validation                                                                                                                                                                                                                                                                                                       | <https://mongoosejs.com/docs/schematypes.html>                                                                                                                                                                                                                                                                                 |                                                                                                         |
| Setup postman tokens dynamically for different user                                                                                                                                                                                                                                                                              | John Udemy 190. Set Token Dynamically in Postman                                                                                                                                                                                                                                                                               |                                                                                                         |
| Mongoose Error Handling                                                                                                                                                                                                                                                                                                          | <p>Task Manager API section</p><p>110. Basic Validation <br>122. Custom Error Handler<br>123. Custom Error Class<br><br><br><br>What was the doubt?<br>I was getting HTML error in postman if user creation (duplicate email) has error<br><br>I was wondering why I am not getting json. To understand this see 122 video</p> | Watch these videos mentioned o left side in the same order to learn validation                          |
| Setup a user as admin (ROLES)                                                                                                                                                                                                                                                                                                    | Udemy 252. User Roles                                                                                                                                                                                                                                                                                                          |                                                                                                         |
| <p>Authorize permissions (Middleware being a function call rather than a callback) <br><img src="https://1944679227-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MVEiPUp08kYt33g51v7%2Fuploads%2FpNisWuGj79l6nddB3lYN%2Fimage.png?alt=media&#x26;token=26ee7ece-ab5b-4601-8dcc-9a0bb5525105" alt=""></p> | Udemy 269. Authorize Permissions - Complete                                                                                                                                                                                                                                                                                    | This is helpful when the user roles are dynamic and we have certain roles hit certain routes in our app |
|                                                                                                                                                                                                                                                                                                                                  |                                                                                                                                                                                                                                                                                                                                |                                                                                                         |
|                                                                                                                                                                                                                                                                                                                                  |                                                                                                                                                                                                                                                                                                                                |                                                                                                         |
|                                                                                                                                                                                                                                                                                                                                  |                                                                                                                                                                                                                                                                                                                                |                                                                                                         |
|                                                                                                                                                                                                                                                                                                                                  |                                                                                                                                                                                                                                                                                                                                |                                                                                                         |
