Performance measurement with ReactJS
suggest changeYou can’t improve something you can’t measure. To improve the performance of React components, you should be able to measure it. React 15 provided add-on tools to measure performance. Import the react-addons-perf module (removed after React 15):
import Perf from 'react-addons-perf' // ES6
// var Perf = require('react-addons-perf') // ES5 with npm
// var Perf = React.addons.Perf; // ES5 with react-with-addons.js
You can use the following methods from the imported Perf module:
Perf.printInclusive()Perf.printExclusive()Perf.printWasted()Perf.printOperations()Perf.printDOM()
The most important one which you will need most of the time is Perf.printWasted() which gives you the tabular representation of your individual component’s wasted time
You can note the Wasted time column in the table and improve a component’s performance using the Tips and Tricks section
Refer the React Official Guide and excellent article by Benchling Engg. on React Performance
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents