• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Abhishek Tanwar

I build web & mobile experiences

  • HOME
  • BLOG
  • CONTACT ME
  • DISCLAIMER & COPYRIGHTS
You are here: Home / Building Web Apps / How to achieve better performance with React and Forms?

How to achieve better performance with React and Forms?

July 9, 2018 by Abhishek Tanwar

Today, I am sharing with you a problem that is common with React from a performance point of view. I would not say problem but rather a development approach.

Problem Statement

React is driven from updates from action to state to view. So if we update something on the state, the DOM changes and causes a re-render. Consider a page with 10-15 inputs including text inputs, checkboxes and drop down with some large datasets. Now when we edit the form in a React controlled form input way (binding everything to state and updating the state when anything changes), any update to a single text box is going to leave your page un responsive. I know, if you have this in normal HTML, it would be ok but that’s just how React concept works.

Why is it like this?

This is just because every update to the state causes a re-render and drop down having multiple nodes is re-rendered on any single character you type in any text box. Leave about the possibility of having the drop down filterable and all.

The Solution

The solution is to implement a good user experience and keep the functionality intact by using below 2 techniques.

Avoid using onChange on Text Input unless it is required

You should always use onBlur for normal text input unless you really want the text input value to dynamically available to state every single character change. This is not the case for 80% of the scenarios.

There is no major change in your code. Just need to use “onBlur”.

[html]
<Input name=’name’ value={name} onBlur={(e) => this.setState({ name: e.target.value })} />
[/html]

Limit the data set for Drop down

In my case I was using Semantic React and the drop down was just hanging because I had a searchable drop down of 3000+ values.  My approach was as below:

  1. By default the drop down can limit to 10 records or so to start with.
  2. When searching, pass a custom filter function and limit the number of records.
solution to slow react dropdowns
solution to slow react dropdowns

My results after these approaches were fantastic. Improved user experience and performance drastically!

Hope this helps!

Let me know approach did you choose for this problem statement?

Share this:

  • Facebook
  • X

Like this:

Like Loading...

Filed Under: Building Web Apps, Tips & Tricks Tagged With: react, react drop down large data, react dropdown, react forms, react setState performance

Primary Sidebar

  • Behance
  • Email
  • Facebook
  • GitHub
  • LinkedIn

Popular Posts

How To Integrate React in JSP Application
SaaS, PaaS, IaaS
XQuery highlighting in Notepad++
Standard Design Patterns – Applied to JAVA
XQDT Installation on Eclipse JUNO

Categories

  • Building APIs
  • Building Mobile Apps
  • Building Web Apps
  • Coding Challenges
  • Extensions
  • Fullstack
  • Patterns
  • Tips & Tricks
  • Uncategorized
  • VSCode

Tags

2022 vscode extensions Abstract Factory alienware amazing vscode extensions apple challenges coding coding-challenges Design Patterns dota2 dota2 items dynamic web service call dynamic webservice invocation enterprise integration express flex helpful vscode extensions how to implement mfa in nodejs increasing productivity using vscode integration pattern macro message channel message endpoint message pattern message router message translator messaging mfa offline action processing offline actions in struts pipes and filters PRG in struts react Steam struts System Emulator threads in struts utilities vscode vscode customization vscode extensions vscode productivity extensions xquery xquery 1.0 xquery design principles

Recent Posts

  • 15+ VSCode Extensions To Improve Your Productivity
  • Productivity and Quality Extensions for ReactJS in VSCode..
  • My goto VSCode plugins for 2022…
  • How to enable MFA for your application in Node.JS?
  • Structuring Express Application – How I do it?

Categories

  • Building APIs (8)
  • Building Mobile Apps (1)
  • Building Web Apps (7)
  • Coding Challenges (3)
  • Extensions (1)
  • Fullstack (6)
  • Patterns (8)
  • Tips & Tricks (41)
  • Uncategorized (43)
  • VSCode (2)

Tags

2022 vscode extensions Abstract Factory alienware amazing vscode extensions apple challenges coding coding-challenges Design Patterns dota2 dota2 items dynamic web service call dynamic webservice invocation enterprise integration express flex helpful vscode extensions how to implement mfa in nodejs increasing productivity using vscode integration pattern macro message channel message endpoint message pattern message router message translator messaging mfa offline action processing offline actions in struts pipes and filters PRG in struts react Steam struts System Emulator threads in struts utilities vscode vscode customization vscode extensions vscode productivity extensions xquery xquery 1.0 xquery design principles

Archives

  • August 2023 (1)
  • March 2022 (1)
  • February 2022 (1)
  • November 2020 (1)
  • April 2020 (2)
  • May 2019 (1)
  • April 2019 (1)
  • March 2019 (1)
  • December 2018 (1)
  • July 2018 (4)
  • June 2018 (3)
  • March 2018 (1)
  • May 2016 (1)
  • December 2015 (1)
  • May 2015 (1)
  • April 2015 (2)
  • March 2015 (1)
  • December 2014 (2)
  • November 2014 (2)
  • October 2014 (1)
  • August 2014 (2)
  • July 2014 (1)
  • April 2014 (1)
  • March 2014 (1)
  • February 2014 (2)
  • January 2014 (1)
  • December 2013 (4)
  • November 2013 (4)
  • October 2013 (3)
  • September 2013 (4)
  • August 2013 (2)
  • July 2013 (5)
  • June 2013 (9)
  • May 2013 (6)
  • April 2013 (2)
  • March 2013 (2)
  • January 2013 (1)
  • November 2012 (2)
  • HOME
  • BLOG
  • CONTACT ME
  • DISCLAIMER & COPYRIGHTS

Copyright © 2025

%d