question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

I’ve installed this package and I’m using it on my react native project like this:

if (process.env.NODE_ENV !== 'production') {
  const whyDidYouRender = require('@welldone-software/why-did-you-render');
  whyDidYouRender(React);
}

But I get no log/error at all.

Do I need to do anything after install package?

"@welldone-software/why-did-you-render": "^3.0.0-beta.5",
"react": "16.8.3"
"react-native": "0.59.2"

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8

github_iconTop GitHub Comments

35reactions
piotrkochancommented, Feb 26, 2020

I’ve added some myComp.whyDidYouRender = true but still there is no logs

2reactions
vzaidmancommented, Apr 5, 2019

copied from the readme:

https://github.com/welldone-software/why-did-you-render#usage

mark all the components you want to be notified about their re-renders with whyDidYouRender like so:

class BigListPureComponent extends React.PureComponent {
  static whyDidYouRender = true
  render(){
    return (
      //some heavy render you want to ensure doesn't happen if its not neceserry
    )
  }
}

Or like this:

const BigListPureComponent = props => (
  <div>
    //some heavy component you want to ensure doesn't happen if its not neceserry
  </div>
)
BigListPureComponent.whyDidYouRender = true

Or track all the components that are matched by their name in the include array like this:

if (process.env.NODE_ENV !== 'production') {
  const whyDidYouRender = require('@welldone-software/why-did-you-render');
  whyDidYouRender(React, { include: [/^pure/], exclude: [/^Connect/] });
}

You probably don’t want the regex way since it will find many many re-renders.

Better focus on your bigger bottleneck components using the first way.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The Best No-Log VPN - Stay Anonymous & Secure - NordVPN
NordVPN keeps no logs of your internet activity. We don't track, collect, or share what you do online. Discover the best private VPN...
Read more >
What Is a No-Log VPN, and Why Is That Important for Privacy?
A no-logs policy is the cornerstone of a VPN service's promise to keep you anonymous. However, it comes with two major issues, both...
Read more >
No-log VPN: What you do online is your business - Surfshark
No -log VPN for ultimate digital privacy · Make sure your ISP has no access to your browsing history · Secure your browsing...
Read more >
12 Best No-Log VPNs in 2022: Anonymous, Proven & Verified
Here Are the Best No-Log VPNs — Tested in December 2022. ExpressVPN — A trustworthy no-logs VPN with excellent security features, P2P-friendly ...
Read more >
Is A No Log Policy Reality Or A Myth In The VPN Industry?
A no log policy is something that is vital to keeping a VPN service as truly private as possible. If your VPN provider...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found