React.js Notes
374 subscribers
72 photos
4 files
48 links
Welcome :)
Public React Notes
Download Telegram
في حاجه جميلة اوي لسا مكتشقها في js
حته كدا. هتحل مشكله اسمها race condition
لما تعمل fetch
ف زي مايكون الداتا بتسابق بعضها مين يوصل الاول ودا بيعمل مشكله
🥰1
ف بتعمل دي الاول
تاني حاجه
تضيف دي تاني ارجيومينت ل فيتش فانكشن
و AbortController دي بتأثر عل البروزر وبس
ملهاش دعوه ب فريم وركس خالص
لانها Browser API يعني
تالت حاجه. ريتيرن فانكشن تعمل abort
ودي بيبق اسمها CleanUp function
بعد كل كدا. في ايرور بيظهر
The user aborted a request
ف اعمله ايرور هاندلينج
if (error.name === "AbortError") return;
4 React UI Components Libraries You Should Be Using

Tremor - https://www.tremor.so/components
Radix-UI - https://www.radix-ui.com/
ShadCN - https://ui.shadcn.com
Next UI - https://nextui.org/
2🥰1
A very great feature in optional chaining.
Naturally, it is for objects. Check if this property exists or not.
But there is something that will benefit you.
It works with function as well
Like this
callback?.()

If this callback function exists? It will be implemented.
If it is not there. Nothing will happen

Here you will need it when you create a custom hook and pass a function to it as another parameter

and take a look at #rules_of_hooks
https://react.dev/reference/rules/rules-of-hooks
🔥31
https://overreacted.io/
Some articles about React.
and the most famous questions about it
🔥1🥰1
🥰2🔥1
⭐️Methodology of how useReducer work⭐️
🔥1🥰1
⭐️Hydration in React⭐️
https://medium.com/@gautamkiran123/hydration-in-react-8e8dff384f93

From here. You will know the difference between CSR and SSR more clearly.
Then we will know what Hydration is.

hydrateRoot() API will compare the rendered content and the server-rendered content and will warn you in case of any mismatches during hydration.

If HTML content is not rendered beforehand you can’t use hydrateRoot() .In this case , createRoot() has to be used.

createRoot() returns an object with two methods — render and unmount

root.unmount() is mostly useful when the root’s DOM node or any of its ancestors gets removed, we can stop removing everything inside that is related to it by calling the unmount method. In simple words, we are telling React to stop with removing the React nodes after we have removed what was necessary , by calling unmount() method.
🥰2🔥1
⭐️ESlint configuration at React with vite⭐️

When initialize React app with vite
npm create vite@latest

don't forget configure Eslint
npm install eslint vite-plugin-eslint eslint-config-react-app --save-dev


And create new file at globally
.eslintrc.json
This file to extend the default rules of ESlint with React rules.
The rules will be like this:
{
"extends": "react-app"
}


Then, in vite.config.js file
import eslint like this:
import eslint from "vite-plugin-eslint"
And add eslint() function inside plugins like this:
plugins: [react(), eslint()],

After that, ESlint will work at your app (★‿★)
🥰4👍2