Supercharge your React App Performance by 10X with these handy tricks.

10 ultimate hacks every Web Developer should know about.

THREAD 🧡 :
1. useState Lazy Initialization With Function

There are times when we need to set the initial value of the state from some variable or from a function that returns a value.
Since our function is in the body, every time a re-render happens, this function is getting called even if its value is not required (we only need it during the initial render).

+ Use the above-mentioned hack to boost performance
2. Monitor Unnecessary Renders in Your Applications

One of the common problems we face is evaluating the necessary renders in your application that are having a bad impact on the performance.
There are different ways we can evaluate them to avoid unnecessary renders in minutes

+ Use this package to do a post-mortem of the app

github.com/welldone-softw…
3. Using React.memo and useMemo

React.memo does a shallow comparison out of the box and avoids rendering.

Memoizing the result will provide a performance boost. This means that React will skip rendering the component and reuse the last rendered result.
4. Deep Comparison in shouldComponentUpdate

Use deep-equal:
npmjs.com/package/deep-e…

Compare two objects and return whether they are equal according to a recursive equality algorithm.
5. React Window

When the list grows long, it’s like a poison is slowly entering your application and having a bad impact on the performance

It starts consuming a lot of memory in the browser. Since all the list items are in the DOM, there is a lag when you scroll the list.
Make use of react-window

github.com/bvaughn/react-…
6. React Query

With hooks for fetching, caching, and updating asynchronous data in React, managing server state is easier than ever before with React Query.
Some of the benefits of using react-query

- Transport/protocol/back-end agnostic data fetching (REST, GraphQL, promises, whatever!)

- Auto Caching + Refetching (stale-while-revalidate, Window Refocus, Polling/Realtime)

- Parallel + Dependent Queries
- Mutations + Reactive Query Refetching

- Paginated + Cursor-based Queries

- Load-More + Infinite Scroll Queries w/ Scroll Recovery

- Request Cancellation

Know more here:
github.com/tannerlinsley/…
7. One Function to Update Multiple Input State Values

This is the common use case of keeping the same function to update multiple input values.

Most of us know about this approach that helps to reduce the code and get our job done.
8. Making Use of Custom Hooks

With hooks, we don’t have some facility that can help us get the callback as in the case of setState.

Make use of custom hooks to reduce the code
For more easy-to-understand hook recipes

usehooks.com
9. Lazy Loading React Components

Lazy loading is the technique of rendering only needed or critical user interface items first, then quietly unrolling the non-critical items later.

The React.lazy function lets you render a dynamic import as a regular component.
10. Pause Console Debugger

This is a lifesaver tip:

Freeze dropdown in browser to inspect it properly

Thanks for stopping by and reading about this

1. Quote Retweet the first and share your thoughts

2. Follow @MakadiaHarsh for more such tips and tricks

Cheer! πŸ₯‚

β€’ β€’ β€’

Missing some Tweet in this thread? You can try to force a refresh
γ€€

Keep Current with Harsh Makadia

Harsh Makadia Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @MakadiaHarsh

15 Sep
Learning programming is hard.

I felt like quitting 6 years back when I started my web development journey.

But I survived in TECH and I love it now.

Here are 21 lessons I wish I'd known earlier in my career.

THREAD 🧡 ↓
{ 1 } Choose a language

There are an unbelievable number of programming languages out there.

But, the thing is, you need to start slow.

Pick one thing at a time and practice as much as possible. Then, you can move on to the next.
{ 2 } Understand a programming concept

You may be tempted to cut corners when learning a new programming language. While it's OK to use Google to find answers, don't by-heart the syntax.

If you don't remember the syntax that's fine, but remembering the concept is a must.
Read 25 tweets
13 Sep
25 Hand-Picked ReactJS Libraries You Probably Didn't Know Existed 😍

Using these will put Web Developer on Steroids.

THREAD 🧡 ↓
{ 1 } React Hot Toast

The Best Toast in Town. Smoking hot React notifications.

Add beautiful notifications to your React App

react-hot-toast.com
{ 2 } React Content Loader

SVG-Powered component to easily create placeholder loadings (like Facebook's cards loading).

skeletonreact.com
Read 28 tweets
10 Sep
17 Killer Websites for Web Developer 🀯

99.8% don't know all of them.

THREAD 🧡 ↓
1. Random Image via API

The most powerful photo engine in the world.

The Unsplash API is a modern JSON API that surfaces all of the info you’ll need to build any experience for your users

source.unsplash.com
2. Embeddable Widget Apps for Notion

Add 3rd party apps embed or create a custom embed for your Notion Document.

apption.co
Read 20 tweets
8 Sep
Hit 8K πŸŽ‰
Thank you everyone! πŸ™πŸ»

I tweet about Web development, No-code Hacks, Life Lessons.

Compound Growth is real! πŸ”₯

0 - 2k ➜ 9 years
2k - 4k ➜ 79 days
4k - 6k ➜ 37 days
6k - 8k ➜ 35 days

Here are top threads 🧡 that'll skyrocket your growth ↓
Optimization of the profile is key for your growth.

Here are a set of concrete, specific suggestions that will help you mold your profile into something that impresses those that read it.

Read More
Tweet Formats that worked for me

Experimenting with different tweet formats is a great way to find out how your tweets resonate with your followers.

Read More
Read 16 tweets
7 Sep
If you want to quickly hack web development, learning no-code tools is an excellent way to go.

Here are some highly useful, resources to guide you in mastering it.

THREAD 🧡:
1. Nocode MBA

No Code MBA teaches you how to turn your idea into reality - all without code.

πŸ”— nocode.mba
2. Nocodery

Code is a thing of the past. Start creating apps and websites easier, faster, and without any special skills.

πŸ”— dev.nocodery.com/tutorials
Read 21 tweets
5 Sep
These 15 life lessons can radically change your life!

They will help you find happiness and keep improving yourself for years to come

🧡
Surround yourself with people who are making better progress than you.
The more you learn, the more you will grow πŸ“ˆ
Read 17 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!

:(