Shan Asif retweeted
When a technology gets a bad reputation but still powers a huge portion of the web (like PHP), it creates a space where: โฌ๏ธ
Shan Asif retweeted
Optimistic vs. Pessimistic Updates in ReactJS:
Which is Your Approach? ๐ค
Optimistic Updates: Swift and Engaging
โ With optimistic updates, you can update the UI immediately, assuming the operation will succeed.
โ Seamless user experience, as changes are instantly reflected.
โ If an error occurs, the UI gracefully reverts, ensuring data integrity.
Pessimistic Updates: Prioritizing Data Consistency
โ For uncertain or critical operations, pessimistic updates shine.
โ By waiting for server confirmation, the UI remains unchanged until success is confirmed.
โ This approach ensures data integrity, making the server the single source of truth.
The Right Choice?
๐ก When deciding between the two approaches, consider the likelihood of success and the importance of data consistency.
๐กOptimistic updates provide responsiveness, while pessimistic updates prioritize integrity.
#javascript #reactjs #nextjs
Shan Asif retweeted
NextJS Tip โก Better Website Optimization with Smarter Font Management:
If you're still using the old manual method of adding links inside the next/head.
Stop doing that; instead, utilize next/font, which lets you optimize your fonts easily and efficiently. ๐๐ป
#nextjs
Shan Asif retweeted
โก๏ธ Check Active Links & Sub-Links in NextJS
โ You can use usePathname() to determine if a link is active.
โ Check if the current pathname matches the href of the link OR the sub-link
Follow @codewithshan (ReactJS / NextJS - Tips & Simplified Code Snippets)
.
.
.
#nextjs
Shan Asif retweeted
JavaScript Tip โก Rest Parameter
๐ It bundles the passing arguments into an array
๐ฎ It allows calling a function with any number of arguments.
๐คฏ Rest parameter must be the last formal parameter
๐ You can also call it a rest Operator
Shan Asif retweeted
JavaScript Tip โก reverse() array method
๐ฅ It reverses and mutates an array.
๐ Returns reversed array.
โ What do you think will be the output?
Shan Asif retweeted
Routing in NextJS is super easy โก
๐คฏ It has a file-based router built on the concept of pages.
๐ When you add a file to the pages directory, it's automatically available as a route.
๐ Any file (react component) inside pages will consider as a route
Shan Asif retweeted
Core Benefits of โก NextJS
๐ Great for SEO | Google will Love You
๐ Super-Fast User Experience
๐ฎ Static Generation | Server-Side Rendering
๐คฉ Perfect for JAMStack
๐คฏ Easy to learn if you're a ReactJS Developer
๐ฑ Pre-Rendering | Image Optimization and much more
Shan Asif retweeted
JavaScript Tip โก some() array method
๐ If any single element passes the test (returns true)
๐คฏ On an empty array, it will return false for any condition!
Shan Asif retweeted
JavaScript Tip โก every() array method
๐ If any single element doesn't pass the test (returns false)
๐คฏ On an empty array, it will return true for any condition!
Shan Asif retweeted
JavaScript Tip โก replace() vs replaceAll()
๐ฅ replace() - first appearance of text and replace it (Use regex to replace all)
๐ Returns a new string and doesn't change the original
๐ฅ replaceAll() - All appearance of text and replace
Shan Asif retweeted
JavaScript Tip โก reverse() array method
๐ฅ It reverses and mutates an array.
๐ Returns reversed array
โ What do you think will be the output?
Shan Asif retweeted
Tool Tip โก Thunder Client (VS Code Extension)
Start testing APIs right inside VS Code.
๐ Hand-crafted lightweight Rest Client for Testing APIs
๐ Alternatively, you can use Rest Client (VS Code extension)
โ What do you mostly use for API Testing (Postman or VS Code)?
Shan Asif retweeted
JavaScript Tip โก Spread Operator
๐คฏ Spread Operator was introduced in ES6
๐ You can use it with an iterable array or object
๐ฅ It allows expanding an array into its components
๐ It helps in the concatenation of an array or object properties
Shan Asif retweeted
JavaScript Tip โก Rest Parameter
๐ It bundles the passing arguments into an array
๐ฎ It allows calling a function with any number of arguments.
๐คฏ Rest parameter must be the last formal parameter
๐ You can also call it a rest Operator
Shan Asif retweeted
CSS Tip โก Responsive iframe
๐ฉโ๐ป When you try to embed YouTube videos, you end up on a non-responsive iframe.
๐ Outside wrapper for the iframe is important
๐ฅ Remove static width and height
๐ Put class on an iframe to handle the positioning
Shan Asif retweeted
Stay focused and productive๐
๐ฉโ๐ป Set goals for the day and break them down into smaller tasks.
๐ Organize your files/folders.
๐ป Track your workday and progress.
โ Set a time limit for each task.
๐ฅณ Take breaks to avoid getting overwhelmed.
๐ Reward yourself.
Shan Asif retweeted
4 standard naming conventions used in modern software development are as follows. Each one defines the specific goal in languages.
๐ฅ Camel: "camelCase"
๐ Snake: "snake_case"
๐ข Kebab: "kebab-case"
๐ Pascal: "PascalCase"
Which one do you use the most?
Shan Asif retweeted
CSS Tip โก BEM
๐ฅ Block Element Modifier (A naming convention)
๐ It helps you to create reusable components (Modular)
๐ฅ Makes your front-end code easier to read and understand
๐ Low Specificity
๐ Use it with CSS preprocessor like Sass
โ Your recent use-case of BEM

















