Slide 1

Slide 1 text

Tools For Measuring React Performance Brenda Jimenez @itreverie

Slide 2

Slide 2 text

React Developer Tools *Available in Chrome, Firefox, etc. @bitreverie

Slide 3

Slide 3 text

Chrome Developer Tools Performance Tab http://localhost:3000/?react_perf

Slide 4

Slide 4 text

React Perf react-addons-perf for React 15 *Available just in Chrome @bitreverie

Slide 5

Slide 5 text

React Performance Devtool react-perf-devtool for React 16 *Available in Chrome and Firefox @bitreverie

Slide 6

Slide 6 text

Printing Results or React Perf – Print Operations Shows DOM manipulations made. We want in the list just the component we are working with!! – Print Wasted Shows time spent on components where the render stayed the same. We want to this list to be empty!! – Print Inclusive Prints the overall time taken – Print Exclusive Times don’t include the times taken to mount the components (processing props, calling componentWillMount and componentDidMount, etc.) @bitreverie

Slide 7

Slide 7 text

shouldComponentUpdate() React.PureComponent The default implementation of this function returns true, leaving React to perform the update React.PureComponent. shallow comparison of current and previous props and state. – simple props and state, or use forceUpdate() when you know deep data structures have changed. – Or, consider using immutable objects to facilitate fast comparisons of nested data. @bitreverie

Slide 8

Slide 8 text

Component Pure Component vs @bitreverie

Slide 9

Slide 9 text

Styles Time Comparison ClassName Function Style Styled-Components @bitreverie

Slide 10

Slide 10 text

React Developer Tools Depending on the frequency of updates, a different color is used: @bitreverie more frequent less frequent

Slide 11

Slide 11 text

Some other tips – Avoid inline styles at all cause Using inline styles causes a huge performance drag. It takes createElement a vast amount of time to go through every defining style and rendering it to the Dom. – Avoid doing anything synchronous in componentWillMount. Anything that is time consuming and requires synchronous time do it in componentDidMount. – Decoupling your application. Firstly you can do code splitting with React Router allowing you to load the code faster.You are separating the rendering trees @bitreverie

Slide 12

Slide 12 text

Thanks Brenda Jimenez @bitreverie @itreverie https://github.com/itReverie/itr-performance-react15 https://github.com/itReverie/itr-performance-react16