神刀安全网

why-did-you-update: Identify Unnecessary Updates in React

Why did you update, bruh?

why-did-you-update: Identify Unnecessary Updates in React why-did-you-update: Identify Unnecessary Updates in React

Wat?

why-did-you-update: Identify Unnecessary Updates in React

A function that monkey patches React and notifies you in the console when unnecessary re-renders occur. Super helpful for easy perf gainzzzzz.

How to

import React from 'react' import {whyDidYouUpdate} from 'why-did-you-update'  if (process.env.NODE_ENV !== 'production') {   whyDidYouUpdate(React) }

To ignore some component names, you can pass an ignore regex

whyDidYouUpdate(React, { ignore: /^Connect/ })

Credit

I originally read about how Benchling created a mixin to do this on a per component basis ( A deep dive into React perf debugging ). That is really awesome but also tedious AF, so why not just monkey patch React.

转载本站任何文章请注明:转载至神刀安全网,谢谢神刀安全网 » why-did-you-update: Identify Unnecessary Updates in React

分享到:更多 ()

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址