ramy ali (@Ramy__Ali) profile picture
Riyadh
Joined August 2011
Problem: Fetching in useEffect is clunky, verbose, and error prone. Solution: Use one of these instead: 1. React Server Components 2. Tanstack Query 3. Tanstack Router loaders 4. React Router loaders 5. Remix loaders 6. RTK Query 7. Apollo 8. swr
38
51
5
464
52,821
💡React tip: you can use a custom hook to handle array states in your components ↓
7
110
2
787
59,156
⚛️ useEffect vs useLayoutEffect: useEffect: asynchronous and it will not delay painting the DOM to the browser. useLayoutEffect: synchronous, and it will delay painting the DOM to the browser. It runs its code just before painting to the browser. ↓
5
113
2
764
51,727
What if the scrollbar went around the corner? 👀 CSS could do that ✨
A scroll indicator that wraps around a rounded corner by @RoberaGeleta
109
529
64
6,236
847,345
Chrome dev team just dropped a video on the bfcache (back/forward cache) An in-memory dump of the whole page including javascript heap so that JS execution state can pick up when the page is restored. Enabled by default, just don’t have a no-store header and no unload event
7
22
1
192
21,885
بعد استخدامه تحقيقًا للجزيرة.. ناشط أمريكي يسخر من ادعاءات الصحفي الشهير بن شابيرو ويكشف أكاذيبه بالأدلة #الجزيرة_مباشر
103
3,474
194
6,677
281,322
graphql was invented by facebook mainly because their frontend evolved very quickly and needed various data views. Creating a new REST end point for each request was too much work. It started harmless, I really just want fields A and B, no need for REST to return all those fields that am not going to use, especially that REST was resource based. I liked that. Although you could already do this in REST with query parameters it was little weird. But then it essentially became let’s bring SQL all the way to the client because we want to write more complex requests. And here is the problem, shortcuts. Creating a new end point is a thoughtful process. Once the requirements are defined, the hope is the existing data model can satisfy the query efficiently, adding the necessary indexes, finding the best way to write the query. Sometimes the requirement is too expensive for the current data model and a redesign may be required for efficiency. The goal is avoid the chatter between backend and db, execute efficient queries to use as little resources as possible. so I can’t really imagine how this can be abstracted away in graphQL without leaking severe performance issues. Anything that hides complexity in favor of less code or simple looking calls is a temporary solution for a painful future realization. SQL itself is a huge abstraction and it takes a long time to really understand. one query might be fast but few months later the same exact query is slow, Code didn’t change but planner changed its mind. adding additional layers on top of it? just makes things way more difficult not easy. so in summary I understand why facebook created graphql, they had a use case, but I doubt 90% of us all out there change the frontend as frequently.
62
193
29
1,693
323,956
API Architectural Styles
6
542
4
2,079
153,403
You might read Composition Over Inheritance. But what does that mean? Inheritance establishes an "Is-a" relationship between a base class and a subclass. It's a quick and intuitive way to share behavior between classes. But make the codebase difficult to maintain. - Subclasses depend on parent class implementation. It is hard to navigate. - Subclasses inherit all parent class behaviors, even if they don't need them. - Overriding parent class behavior can introduce bugs. Composition forms a "Has-a" relationship. The idea is to build more complex objects by combining simpler objects. - Components are reusable across different classes. - It's easy to change behavior at runtime by changing the components of a class. - Smaller, self-contained components are easier to change. - Components are independent and interact through well-defined interfaces, reducing their dependencies. Pros of Composition: - Improve testability of individual components. - Easy to change independent components. - Promotes encapsulation and Single Responsibility Principle. Cons of Composition: - Increase the number of objects in a system. Favoring composition over inheritance doesn’t mean inheritance is an obsolete concept. It remains useful, especially when polymorphism and hierarchies model the problem domain. What are your thoughts?
22
97
6
526
127,007
⚛️ Do you know how to name React components with the Base + Composite + Suffix Pattern? You can use this pattern to create clear and consistent component names in your projects.
6
98
4
687
76,176
⚛️ I've reviewed countless of PRs and I have seen this React mistake over and over. ❌ An object ref doesn't notify about changes to the ref value in useEffect. ✅ Instead use a ref callback function to always get the latest ref value.
6
90
2
624
64,633
🔥 Tip: Use useImperativeHandle to call functions of your child components in React! Thanks @fernandorojo to pointing me the right way!
6
11
3
176
22,989
CSS Tip! 🤙 You can create this magnetic :hover effect with CSS anchor positioning, :has, and zero JS 🔥 article { anchor-name: --develop; } ul:has(li:hover) { --anchor: --develop; } ul::after { inset: anchor(var(--anchor) top) anchor(var(--anchor) right) ... ; } How do you keep it clean when entering/exiting the list? Use transition-delay ⭐️ ul:has(li:hover) { --active: 1; } ul::after { opacity: var(--active, 0); transition: opacity 0.2s, inset 0.2s 0.2s; } ul:hover::after { transition: opacity 0.2s 0.2s, inset 0.2s; } This is a cool trick you can use. Delay the opacity on enter and then delay the position on exit. That way you don't get a weird effect on enter/exit 🙏 This one's a "Future" CSS tip 🔮 But, the demo will work in all browsers in some way. The idea is to progressively enhance it. 1. No JavaScript and no Anchor Positioning? Highlight on hover ✏️ 2. No Anchor Positioning? Use JavaScript with a single event listener to update the inset values using elementFromPoint and .closest 🫶 3. If there is Anchor Positioning support, use that and don't fire the JavaScript. You can check with CSS.supports('anchor-name: --anchor') ✨ That's it! @CodePen link below! 👇
Nice effect 💫 Do you know how to do this?
43
641
36
4,796
731,085
Components of a URL
8
242
2
975
92,581
Explaining 9 types of API testing. Next week's topic will be listed at the end. 🔹 Smoke Testing This is done after API development is complete. Simply validate if the APIs are working and nothing breaks. 🔹 Functional Testing This creates a test plan based on the functional requirements and compares the results with the expected results. 🔹 Integration Testing This test combines several API calls to perform end-to-end tests. The intra-service communications and data transmissions are tested. 🔹 Regression Testing This test ensures that bug fixes or new features shouldn’t break the existing behaviors of APIs. 🔹 Load Testing This tests applications’ performance by simulating different loads. Then we can calculate the capacity of the application. 🔹 Stress Testing We deliberately create high loads to the APIs and test if the APIs are able to function normally. 🔹 Security Testing This tests the APIs against all possible external threats. 🔹 UI Testing This tests the UI interactions with the APIs to make sure the data can be displayed properly. 🔹 Fuzz Testing This injects invalid or unexpected input data into the API and tries to crash the API. In this way, it identifies the API vulnerabilities. Next week, we will talk about: - Our recommended materials for cracking your next technical interview (YouTube) - How mobile releases work - 12 Tips for API security - What can go wrong with Caching - Log parsing tips Subscribe to our weekly newsletter so you won't miss it: bit.ly/3KCnWXq
21
760
13
3,088
455,839
⚛️ React Tip: re-renders can be avoided by rethinking your component's structure and embracing composition ↓
16
97
672
66,356
🇮🇱🇵🇸 US taxpayer dollars just funded the bombing of a CHRISTIAN HOSPITAL in Gaza. Here are some of the children who survived the massacre. nitter.cf/WarMonitors/status/171…
2,494
38,007
3,982
58,343
3,069,036
🇮🇱🇵🇸 The death count is up to 810+ after Israel bombed Gaza’s Baptist hospital. This is a massacre. GRAPHIC VIDEO nitter.cf/WarMonitors/status/171…
2,897
25,988
3,988
42,898
2,867,263